The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 25: The Architecture of Scala Collections
Return to errata index.

Page 575 (PDF page 609):
In Listing 25.2, class TraversableLike should be trait TraversableLike.

[Fixed.]
Page 578 (PDF page 612):
In Listing 25.3, the signature of map names the function to apply
"(p: Elem => B)", but it is then referred to as "f" in the body.

Obviously, the signature should be "... (f : Elem => B) ..."

(Personally, I would like f : A => B even better, but thats for
didactic purposes, I think).

[I concur. I changed p to f. Left Elem and changed A to Elem later. A is
what it is called in reality. We called it Elem in the book to help
readers keep track of which type was the element type.]
Page 578 (PDF page 612):
In Listing 25.3, the signature of the map method is wrong. Type
CanBuildFrom[B, That, This] should be CanBuildFrom[This, B, That] instead.
Page 578 (PDF page 612):
Concerning my first erratum:

It really should be "f : A => B" rather than "f : Elem => B", because
the first version re-occurs on page 587, so "f : A => B" would
be consistent, where "f : Elem => B" is not.

[I changed A to Elem here for consistency.]
Page 580 (PDF page 614):
The four bases of RNA are in fact AUCG, not AUTG, where 'C' stands for
'cytosine'. 'T' and 'U' are two versions (DNA vs RNA) of the same base.
Page 583 (PDF page 617):
Missing "override" in the "take" method implementation (bottom of the
page):

def take(count: Int): RNA1 = RNA1.fromSeq(super.take(count))
Page 581 (PDF page 633):
In Listing 25.6, I think "groups" in the definition of the class RNA1
should be private:

final class RNA1 private (private var groups: Array[Int], val length:
Int) ...

Otherwise clients can mutate the contents very easily, e.g.

rna1.groups(0) = 0
Page 590 (PDF page 642):
"..a Patricia trie storing the three strings "abc", "abd", "al", "all",
"xy" would.."

That's five strings, but simply remove "three".

[Math to the rescue. I added two to the "three" and changed it to "five".]
Page 595 (PDF page 647):
In Listing 25.11, the definition of PrefixMap contains a superfluous
"extends" clause. It doesn't do any harm, as the code compiles and runs
fine with or without it. Still it has no purpose there, just makes the
code more complex and confusing.

[Fixed.]

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.