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.
-
-
Replying to @propensive
If f contains a recursive call to the enclosing method in tail position, only the pattern matching approach supports tailrec optimization. You can't write this using map or fold:pic.twitter.com/c3GzL8RLIb
2 replies 8 retweets 36 likes
Replying to @tomas_mikula
Good point, I hadn't thought of that!
2:36 AM - 5 Apr 2018
from Petersfield, England
0 replies
0 retweets
3 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.