p.25 "popular in academics" Should this perhaps be "popular in academia" or "popular with academics" ?
p.26 Should "name-less" be "unnamed" or "nameless" ?
p. 49 "If an anonymous function consists of one statement that takes a single argument, you need not explicitly name and specify the argument"
Note that we can't do the following:
list.foreach(throw) list.foreach(return)
Should "statement" be "function name" ?
p56 "any type into an apply method call, not just arrays." The word apply should have a different font (the font for code not for prose). Also, the "not just arrays" pertains to "any type" not "an apply method call" so perhaps it should be "any type, not just arrays, into an apply method call."
p64 treasureMap += 1 -> "Go to island."
The compiler reports that this use of "+=" is deprecated; the scaladocs advise "use += Pair(key, value)" Further, the line is being parsed as (treasureMap += 1) -> "Go to island." so the discussion on p65 is currently inaccurate. Changing the code to treasureMap += (1 -> "Go to island.") would avoid the deprecation warnings and make the discussion accurate.
p69 "The Scala compiler transforms the fields and methods of a singleton object to static fields and methods of the resulting compiled Java class." This can be true for methods (if the object has no companion class), but is not true for fields: they are never compiled to static fields. We can see this by running javap on the compiler output.
p70 "it will create ... a static method named worldify" Not true. $ scalac WorldlyGreeter.scala $ ls *.class WorldlyGreeter$.class WorldlyGreeter.class $ javap -private WorldlyGreeter | grep static $ javap -private WorldlyGreeter$ | grep static public static final WorldlyGreeter$ MODULE$; public static {};
So WorldlyGreeter.worldify(greeting) effectively gets compiled into the Java WorldlyGreeter$.MODULE$.worldify(greeting)
The later text is sufficient: "Note [also] that in ... you invoke the companion object’s worldify method using a syntax similar to the way you invoke static methods in Java: ..."
p72 "any Scala class with a main method" should be "any Scala object with a main method" or more accurately "any stand-alone Scala object with a main method"
[Observation, not a suggested change to the book] "and returns Unit" Curiously, if we run the program using "scala" instead of "java", the return type of main seems to be irrelevant.
p73 "Class WorldlyGreeter’s greet method passes the "Hello, world!" String to which worldlyGreeting refers to println, ..." This is hard to read.
Perhaps either leave out "to which worldlyGreeting refers" or use two sentences: * Class WorldlyGreeter’s greet method passes to println the "Hello, world!" String to which worldlyGreeting refers. * println sends the cheerful greeting, via the standard output stream, to you.
p74 "implements is not a keyword in Scala" implements should be in the font for code. (For example, Java keywords switch and break are in the font for code on p138)
p85 (subjective) "cc will always refer to the same ChecksumCalculator object with which you initialize it" should this perhaps be "cc will always refer to the particular ChecksumCalculator object with which you initialize it" or "cc will always refer to the same ChecksumCalculator object"
p86 "If you really need a parameter to be a var, you can achieve this by placing var in front of the parameter, as in def add(var b: Byte)" This does not compile. It only works for primary constructor parameters.
"First, the return statement at the end of the checksum method is superfluous and can be dropped." Should say return keyword not return statement. The statement is the whole line, and can't be dropped.