Page 270 (PDF page 310):
At the bottom of the page it reads, "all arguments in the parameter list
of a case class implicitly get a val prefix, so they are maintained as
fields".
This is true, but strictly speaking it is true of any class. The
difference is that in a normal class the fields are not public.
abstract class Expr
class Var(name: String) extends Expr {
def printName() = println(name)
}
object ScalaApp {
def main(args : Array[String]) : Unit = {
val v = new Var("x")
v.printName() // prints "x"
// println(v.name) // Error: value name is not a member of Var
}
}
|
Page 271 (PDF page 311):
Add case class's copy method to index.
|
Page 273 (PDF page 313):
In the first paragraph of the "match compared to switch" subsection you
wrote:
"First, match is an expression in Scala, i.e., it always results in a
value."
May be it would be more accurate to precise: ".... i.e., it always
results in a value if no exception is thrown during the evaluation."
For instence the code:
val i = 3
println(i match {
case 3 => 3/0
case _ => "other"
})
Will throw an exception and the match expression will not result in a
value.
Ps: great book!!
|
Page 285 (PDF page 325):
The running example for pattern matching is broken because it won't
simplify expressions like -(-x+0) or x*(1+0). You have to simplify
subterms first, and only then apply the patterns.
|
Page 289 (PDF page 329):
2nd to last paragraph
2nd to last sentence
"For Scala, the approach would not work at all, because it is possible to
store value types..."
should perhaps be:
"For Scala, the approach would not work at all, because it is *only*
possible to store value types..."
|
Page 301 (PDF page 341):
"r is placed between parentheses"
should say "oper is placed between parentheses"
|