Page 48 (PDF page 82):
"Both mutable and immutable sets offer a + method, but their behavior
differs. Whereas a mutable set will add the element to itself, an
immutable
set will create and return a new set with the element added."
This statement is incorrect, + semantics does not change. Example below:
import scala.collection.mutable.Set
val first = Set("A", "B")
val second = first + "C"
println(first)
println(second)
"first" set is not altered.
|
Page 55 (PDF page 89):
Listing 3.10 works in Scala 2.7, not in 2.8. Here are the necessary
changes:
import scala.io.Source
if (args.length > 0) {
// Changes: fromFile now requires a file, not a String; use fromPath
// getLines must be getLines()
// newline not returned; use println instead of print
for (line <- Source.fromPath(args(0)).getLines())
println(line.length + " " + line)
println()
}
else
Console.err.println("Please enter filename")
|
Page 45 (PDF page 89):
execute thrill.sort((s,t)=> s.charAt(0).toLower< t.charAt(0).toLower)
gives
"error: value sort is not a member of List[String]"
should use method "sortWith"
|
Page 55 (PDF page 99):
(Based on the Safari version)
The code in listing 3.10 works as-is in Scala 2.9, and the existing
erratum for this page is misleading. Source.fromPath() appears to have
been removed, and Source.fromFile() accepts a single string argument.
|
Page 57 (PDF page 101):
Code listed in 3.10 and 3.11 does prints the file in a singleline, and
not as specified in the example in the book.
The
print(padding + line.length + " | "+ line)
should be
println(padding + line.length + " | "+ line)
|