For the following map signature, am I reading it correctly?
object OptionImpl extends Option {
def map[B](f: A => B): Option[B]
}
source - FP in Scala
[B] means only objects of type B can call this function
f: A => B means that it accepts 1 argument, a function, that returns the same type B
I'm fuzzy on a concrete example of this function.
Bis just a wildcard (i.e. generic). It just says that these two types are the same:That is, it says: if you pass me a function that converts
As toBs, I will give you back anOptionthat may contain aB(whereBcan be any type).