There are two ways to define PF: 1) with literal case {}
syntax and 2) as explicit class. I need the following function throw a MatchError, but in the second case that doesn't happen.
1) with case
val test: PartialFunction[Int, String] = {
case x if x > 100 => x.toString
}
2) as class
val test = new PartialFunction[Int, String] {
def isDefinedAt(x: Int) = x > 100
def apply(x: Int) = x.toString
}
Should i, in the seconds case, manually call isDefinedAt
, shouldn't it be called implicitly by the compiler?