The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 22: Implementing Lists
Return to errata index.

Page 469 (PDF page 505):
The source code for object Nil (listing 22.1) and case class :: use the
override modifier for isEmpty but not for head and tail.

According to section 10.8 the override modifier is mandatory in Scala and
chapter 22.1 introduced isEmpty, head and tails as abstract methods in
class List.
Page 476 (PDF page 512):
The package for the ListBuffer class should be scala.collection.mutable
instead of scala.collection.immutable
Page 477 (PDF page 513):
On page 477, in the first line of body of the method '+=', we have:
if (exported) copy()

I checked the scaladoc of the class ListBuffer, but I did not any method
called 'copy()', where is it defined?
Page 578 (PDF page 612):
In the code listing 25.3 it can be read:
"def map[B, That](p: Elem => B)(implicit bf: CanBuildFrom[B, That,
This]): That" since CanBuildFrom definition is "CanBuildFrom[-From,
-Elem, +To]" I expected to read "...(implicit bf: CanBuildFrom[This, B,
That]): That" so I downloaded Scala's source code and found the
definition was wrongly typed in the book. On the other hand, the function
parameter name is "p" whereas it is referred as "f" below.

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.