The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 2: First Steps in Scala
Return to errata index.

Page 32 (PDF page 77):
There is a qwertist statement in the second paragraph. Welcome relief to
right little finger doesn't hold true for dvorak typists.
Page 33 (PDF page 78):
You write that args.foreach(println) "takes advantage of a special
shorthand". But this piece of code is actually just using a function as
first-class object.

Additionally, you write that "if a function literal consists of one
statement that takes a single argument, you need not explicitly name and
specify that argument". Again, this is just using a function as a value,
and it is not restricted to functions of one argument.

The text in the footnote about "partially applied functions" is just
showing off, it's not really relevant to that text...
Page 45 (PDF page 89):
In "Table 3.1 Some List methods and usages" the examples

thrill.remove(s => s.length == 4) and
thrill.sort((s, t) => s.charAt(0).toLower < t.charAt(0).toLower)

are valid and working but they are deprecated in Scala 2.8.1. The
documentation of the Scala Standard Library recommends the usage of the
filterNot instead of the remove method and sortWith instead of the sort
method.
Page 69 (PDF page 113):
The last paragraph on page 113 says

"...Thus if you try to run Summer.scala as a script, the Scala
interpreter will complain that Summer.scala does not end in a result
expression (assuming of course you didn’t add any expression of your own
after the Summer object definition)..."

but what happens when trying to execute the Summer.scala as a script with
the command

scala Summer.scala

is that it ends up with the compiler complaining about
ChecksumAccumulator is not being found when the
ChecksumAccumulator.calculate is imported:

error: not found: value ChecksumAccumulator
import ChecksumAccumulator.calculate

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.