Skip to content

Instantly share code, notes, and snippets.

@divarvel
Created April 7, 2014 13:46
Show Gist options
  • Save divarvel/10020595 to your computer and use it in GitHub Desktop.
Save divarvel/10020595 to your computer and use it in GitHub Desktop.
Type inference with curried functions
scala> Some("yolo").fold(Nil)(List(_))
<console>:8: error: type mismatch;
found : List[String]
required: scala.collection.immutable.Nil.type
Some("yolo").fold(Nil)(List(_))
^
scala> Some("yolo").map(List(_)).getOrElse(Nil)
res1: List[String] = List(yolo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment