def getOp(i : Int) : Option[Int] = if(i==1) None else Some(i) val list = List(1,2,3,4) list.flatMap(getOp) foreach println
If you see the code for flatMap of List, it has the signature -
flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That
It expects a function that can translate A to GenTraversableOnce[B]. But in my code I am passing a function that returns an Option. But Option does not extend GenTraversableOnce. So I am guessing some implicit is doing this? How can I find that implicit?