Created
May 19, 2014 15:32
-
-
Save nicholasren/ddecb1b30578565dd938 to your computer and use it in GitHub Desktop.
scala training example - pattern matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Option[T] | |
case class Some(t: T) extends Option[T] | |
case class None extends Option[T] | |
val possibleNumber = Some(1) | |
val numbers = possibleNumber match { | |
case Some(x) => x | |
case None => 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment