GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Wednesday 16 June 2004
Chapter 5, Exercise 8

Sorry, got busy for a few days. (SLO Road Trip and MTB campout at Montaña de Oro State Park.) So Ex.8 asks In the section titled "Class access" you'll find code fragments describing mylib and Widget. Create this library, then create a Widget in a class that is not part of the mylib package.

THECLAPP's entry is here. However, it looks like we're not quite in synch: what he calls ex. 9 is ex. 8 in the version of TiJ that I have (3rd ed., Revision 4.0).

Well, each code fragment is barely more than a one-line header. But anyway, here is c5x8_mylib.scala:

package c5x8_mylib;
// Classes are public by default in Scala.
class Widget {
    Console.println( "Creating a c5x8_mylib.Widget." );
    def boo = Console.println( "Boo!" );
}

And then here is the guy who creates that Widget:

package x;
object c5x8_main {
    def main ( args: Array[String] ) = {
        val w = new c5x8_mylib.Widget;
        w boo;
    }
}

Note that I call w.boo without the dot, using "boo" as if it were a postfix unary operator. Whee. Also note that the constraint mentioned in the text of this section (only one public class per compilation unit, with its name having to match the source file name) does not apply in Scala.

And also note that a Scala plugin for Eclipse has been announced on the Scala mailing list. Details later.
11:42:00 PM   comment/     



Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/2/6; 12:40:44 .
Click here to send an email to the editor of this weblog.

June 2004
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
May   Jul

Previous/Next