The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 8: Functions and Closures
Return to errata index.

Page 149 (PDF page 181):
First example of the Partially Applied Functions (PAF) section:

someNumbers.foreach(println _)

And soon after, this quote (pertaining to it):

"Thus, the underscore in this case is not a placeholder for a single
parameter. It is a placeholder for an entire parameter list."

Just looking at "println _," this is true. But that's not all of the
code. In fact, '_' is first used as a placeholder (as in Placeholder
Syntax, the previous section) to someNumber's foreach, then substitutes
println's arg list with that placeholder (..and, hence, becomes a
Partially Applied Function).

So I think, firstly, the quoted text is confusing, especially considering
the PAF section follows on the heels of the PS section. But I also think
the example is powerful, as it shows '_' used as PS and PAF in the same
statement. The latter text does a good job of explaining PAF as its own
construct. Stylistically, I suggest this example close the PAF section,
not open it, and mention the combined usage.
Page 163 (PDF page 206):
The last sentence of the **Section 8.9**:

"If you don’t fully understand tail recursion yet, see Section 8.9"

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.