Skip to content

Instantly share code, notes, and snippets.

@maiha
Created October 20, 2010 06:22
Show Gist options
  • Save maiha/635883 to your computer and use it in GitHub Desktop.
Save maiha/635883 to your computer and use it in GitHub Desktop.
Concatenate PatialFunction.scala
object ascii {
def a: PartialFunction[String, Int] = { case "a" => 97 }
def b: PartialFunction[String, Int] = { case "b" => 98 }
def ab = a orElse b
}
ascii.a("a") => 97
ascii.a("b") // scala.MatchError: b
ascii.ab("a") => 97
ascii.ab("b") => 98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment