This code applies a function to List of Ints and sets each value in the List of Option with value 4 :
val l = List(1,2,3,4,5) //> l : List[Int] =
val v = 4 //> v : Int = 4
def g(v:Int) = List(v-1, v, v+1) //> g: (v: Int)List[Int]
l map (x => {f(x);}) //> res0: List[Option[Int]] = List(Some(4), Some(4), Some(4), Some(4), Some(4))
Signature of map :
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
Since B is the first type parameter (in map[B, That]) does this mean its typed to the prefix operand 'l' (List) ?
How is 'A' typed ? Does the scala compiler somehow check the type within the the List 'l' and infer that its of type Int ?
How is 'That' typed ?