The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 7: Built-in Control Structures
Return to errata index.

Page 118 (PDF page 162):
The code listed below listing 7.3 behaves differently than the book
states:
  scala> def greet() {println("hi")}
  greet: ()Unit

  scala> greet() == ()
  <console>:9: warning: comparing values of types Unit and Unit using
`==' will always yield true
              greet() == ()
                      ^
  hi
  res0: Boolean = true

Book doesn't mention the warning until the next, "Java style" listing on
the next page (163-pdf).
Page 124 (PDF page 168):
Executing the code in Listing 7.9 with scala 2.9.0.1 gives the following
error:

error: value trimmed is not a member of List[String]
possible cause: maybe a semicolon is missing before `value trimmed'?
    trimmed = line.trim
    ^
one error found

Adding a semicolon as suggested, i.e.:

  line <- fileLines(file);

fixes the problem
Page 125 (PDF page 169):
The first line:
"the last expression of the block"
should be
"the first expression of the block"
Page 132 (PDF page 176):
Listing 7.16 does not give the same result as the Java example it is
supposed to "transliterate".  The counter variable i is incremented one
more time than in the Java example because of the lack of a break
statement.
Page 133 (PDF page 177):
The word "is" is missing in the following sentence:

"Here an example how this library-supplied break method could be applied:"
Page 133 (PDF page 177):
There is a grammatical error in the following sentence.

"Class Breaks in package scala.util.control
offers a break method, which can be used to exit the an enclosing block
that’s marked with breakable."

The phrase "exit the an enclosing block" has two consecutive articles.

Page number: Book type: Paperback book PDF eBook
Book version: (Or build date. Found on back of title page.)
Your feedback:
Your name: (optional)
Your email address: (optional) (will not be published)

Copyright © 2021 Artima, Inc. All rights reserved.