Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created February 2, 2015 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/3edbb599efe6ab91ed5f to your computer and use it in GitHub Desktop.
Save shigemk2/3edbb599efe6ab91ed5f to your computer and use it in GitHub Desktop.
val i = 0
// i is an integer
i match {
case 1 => println("January")
case 2 => println("February")
case 3 => println("March")
case 4 => println("April")
case 5 => println("May")
case 6 => println("June")
case 7 => println("July")
case 8 => println("August")
case 9 => println("September")
case 10 => println("October")
case 11 => println("November")
case 12 => println("December")
// catch the default with a variable so you can print it
case whoa => println("Unexpected case: " + whoa.toString)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment