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.
|