List(1, 2, 3).flatMap { a => if(a == 2) None else List(Some(a)) } // List(Some(1), Some(3)) // #Scala, spot the bug!
-
-
Replying to @puffnfresh
@puffnfresh That's trivial. None gets converted into a List[Option[Int]]().2 replies 0 retweets 0 likes -
-
Replying to @dcsobral
@puffnfresh Well, technically, Iterable[Some[Int]](), I suppose.1 reply 0 retweets 0 likes -
Replying to @puffnfresh
@puffnfresh It expands to this: List(1, 2, 3).flatMap((a => if (a==2) Option.option2Iterable(None) else List(Some(a))))(List.canBuildFrom)1 reply 2 retweets 0 likes -
Replying to @puffnfresh
@puffnfresh That option2Iterable is there so people can mix Option with Iterables on for comprehensions.2 replies 0 retweets 0 likes
Replying to @dcsobral
@dcsobral @puffnfresh Ah yes. Seen on mailing list a few times: optA zip optB, expect Option, get Iterable. Though I think zip exists now.
9:09 AM - 20 Dec 2013
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.