This code applies the function to the List of Ints and sets each value in the parameter list with a value of 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))
Card Signature:
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
Since B is a parameter of the first type (on the map [B, That]), does this mean that it is typed on the prefix operand 'l' (List)?
How is βAβ dialed? The scala compiler somehow checks the type in the list "l" and concludes that its type is Int?
How is βThisβ typed?
source share