Skip to content

Instantly share code, notes, and snippets.

@stephenLee
Created September 20, 2012 05:13
Show Gist options
  • Save stephenLee/3754082 to your computer and use it in GitHub Desktop.
Save stephenLee/3754082 to your computer and use it in GitHub Desktop.
Scala Option example
val capitals = Map("France" -> "Paris", "Japan" -> "Tokyo")
capitals get "France"
capitals get "North Pole"
def show(x: Option[String]) = x match {
case Some(x) => x
case None => "?"
}
show(capitals get "Japan")
show(capitals get "France")
show(capitals get "North Pole")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment