Not sure, but isn't it basically the Option[A] that you would want to convert using f? Applying a map() to the Option[A] means you will get an Option as a result, but your function f is applied to the actual value inside the Option i.e. an instance of A. It's a bit like using a map() on a List i.e. your mapping function is applied to each individual element inside the List (e.g. A=>B), but you still get a List out.
So you now have a way to use the function f, which turns an A into a B, to convert an Option[A] to an Option[B], which is what lifting does.
Actually for the last 4 months, I have been doing C# and all the knowledge and experience that I had when I worked with Scala last year seems to be slowly diminishing. Honestly it took me some couple of minutes to understand what that function was doing. I have been out of Java programming for the last 3 years, but I could still pick up any legacy Java code base and understand it on the fly. That seems to be a bit difficult with Scala!
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
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: