Scala Partial Functions
Resources
Basics
From this lecture.
trait PartialFunction[-A, +B] extends (A => B) {
def apply(x: A): B
def isDefinedAt(x: A): Boolean
}
// how to use
val simplePF: PartialFunction[Int, Int] = {
case 1 => 42
case 2 => 65
case 3 => 999
}