Your assessment of infix notation is correct, but your understanding of placeholder parameters is erroneous.
When using underscore as a placeholder parameter, you create a function. The question is what are the boundaries of this function: where does it start, where does it end? For example, consider this expression:
_ + _ + _
How to translate it? Here are a few alternatives:
(x, y, z) => { x + y + z } (x, y) => { (z) => { x + y } + z } (x) => { x + { (y, z) => y + z } }
Well, the Scala rule is that the scope is the innermost expression, delimited by parentheses, or the whole expression otherwise. So, in practice, you wrote two different things:
x("a" + _.toString) // is the same thing as x((y) => "a" + y.toString) x("a".+(_.toString)) // is the same thing as x("a".+((y) => y.toString))
source share