Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Last active January 3, 2016 15:49
Show Gist options
  • Select an option

  • Save kevinmeredith/8485124 to your computer and use it in GitHub Desktop.

Select an option

Save kevinmeredith/8485124 to your computer and use it in GitHub Desktop.
scala> els
res4: Int = 222
scala> opt
res5: Some[Int] = Some(1)
scala> opt.foldLeft(els)((_,elem) => identity(elem))
res9: Int = 1
scala> val optNone: Option[Int] = None
optNone: Option[Int] = None
scala> optNone.foldLeft(els)((_,elem) => identity(elem))
res10: Int = 222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment