Skip to content

Instantly share code, notes, and snippets.

@ScalaWilliam
Created December 14, 2013 16:37
Show Gist options
  • Save ScalaWilliam/7961511 to your computer and use it in GitHub Desktop.
Save ScalaWilliam/7961511 to your computer and use it in GitHub Desktop.
scala> val myMap = Map("test"->"best")
myMap: scala.collection.mutable.Map[String,String] = Map(test -> best)
scala> val fn = myMap.lift
fn: String => Option[String] = <function1>
scala> (fn("test"), fn("lest"))
res5: (Option[String], Option[String]) = (Some(best),None)
scala> myMap("lest") = "zest"
scala> (fn("test"), fn("lest"))
res7: (Option[String], Option[String]) = (Some(best),Some(zest))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment