Skip to content

Instantly share code, notes, and snippets.

@esuomi
Created April 1, 2013 18:15
Show Gist options
  • Save esuomi/5286625 to your computer and use it in GitHub Desktop.
Save esuomi/5286625 to your computer and use it in GitHub Desktop.
Quick pattern match test with Strings.
object worksheet {
def call[T](t:T, s:String) : (T,String) = { (t, s) }
//> call: [T](t: T, s: String)(T, String)
call("foo", "bar") match {
case (x, "bar") => println("found bar")
case (x, "baz") => println("found baz")
} //> found bar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment