Stop using, opt match { case Some(x) => f(x); case None => y } Stop using, http://opt.map (f).getOrElse(y) Use, opt.fold(y)(f) I feel like I'm very late to this party.
I mean, if you statically know it's a Some, you can statically .get it. Or am I missing something?
-
-
you're missing that that's not the "not play nicely" Olaf means. scala> Option(1).fold(Nil)(_ :: Nil) <console>:12: error: type mismatch; found : List[Int] required: scala.collection.immutable.Nil.type Option(1).fold(Nil)(_ :: Nil) ^
-
Ah, yes I was! (Fixed in Dotty, though. :) )
- Show replies
New conversation -
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.