GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Monday 3 May 2004
Chapter 2, Exercises 7-9, Thinking in Scala

I'm trying a new tack. Maybe a little less error prone than trying to slip Scala source code past Radio UserLand's text munger. Unfortunately, UserLand's restrictive filename policy requires that I rename these as foo.scala.txt. Sorry.

Later: scratch that, I didn't like how that worked.

This entry corresponds to http://theclapp.blog-city.com/read/9551.htm . There's nothing very new here ...

Chapter 2, Exercise 7

Print three args from the command line
object c2x7 {
    def main ( args : Array[String] ) = {
        Console.println( "Arg 1: " + args( 0 ) );
        Console.println( "Arg 2: " + args( 1 ) );
        Console.println( "Arg 3: " + args( 2 ) );
    }
}

Chapter 2, Exercise 8

AllTheColorsOfTheRainbow -- not really colors, just member access
class AllTheColorsOfTheRainbow {
    var anIntegerRepresentingColors : Int = _ ;
    def changeTheHueOfTheColor ( newHue : Int ) =
        anIntegerRepresentingColors = newHue;
};
object c2x8 {
    def main ( args : Array[String] ) = {
        var atcotr = new AllTheColorsOfTheRainbow;
        atcotr.changeTheHueOfTheColor( 10 );
    }
}

Chapter 2, Exercise 9

HelloDate (javadoc -> scaladoc)

//: c2x9.scala
/** The first Thinking in Scala example program.
 * Displays a string and today's date.
 *
 * @author Bruce Eckel
 * @author www.BruceEckel.com
 * @translator (into Scala) Doug Landauer
 * @version 2.0
*/
package x;
object HelloDate {
  /** Sole entry point to class & application
   *
   * @param args array of string arguments
   * @return No return value
   * @exception exceptions No exceptions thrown
  */
  def main ( args : Array[String] ) = {
    Console.println("Hello, it's: ");
    Console.println(new java.util.Date());
  }
} //\/:~

Here, we learn that the stuff inside scaladoc comments has to be sorta reasonable xhtml. I had to escape the ampersand. Scaladoc created 9 .html files for this example. I copied the one for the x package here. It does look better in context.

Update: Sorry, it was 54 .html files. I copied some of them up to here. You want to click on package x, Object HelloDate in order to see the part that's relevant to this exercise. Most of the other links won't work because I didn't upload their files.

Note that scaladoc (and, I imagine, javadoc) creates the .html files for the package in the same subdirectory where that package's .class files are generated.
11:31:42 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:38:54 .
Click here to send an email to the editor of this weblog.

May 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 31          
Apr   Jun

Previous/Next