Hi,
In Scala, _ is useful in many contexts.
Here are some examples:
What follows the map is a function. In the first form we are explicitly naming the function argument.
The second form is terse - but means the same thing. We are not naming the argument (we don't need to).
Now consider the following:
If we try to use the terse form, we get an error.
When you repeat the _, each occurrence refers to successive arguments. As we are passing in just one element
(which is a pair), there is just one argument, so _._2 is erroneous.
Following contrived snippet shows the successive arguments form:
_ is used in Scala in many contexts (pattern matching don't care) - and for creating partially applied functions:
Hope this helps...
--- regards atul