Hacker News new | ask | show | jobs
by saagarjha 2258 days ago
If the team had just written Haskell for a year they would have picked the obviously superior "fold" name for this operation. (I think you can actually use fold here if you really wanted it, since Option implements IntoIter?):

   Some(0).iter().fold("some", |_, _| "none")
1 comments

For people coming from a functional programming background, `fold` might be the superior name. But setting aside monads, `map_or` expresses the intent much better I find.
(I was being mostly sarcastic.)
Rereading your comment I wonder how I could miss this!