Using partial functions in Scala – how does it work?
A partial function is a function that is valid for only a subset of values of those types you might pass in to it. For example: val root: PartialFunction[Double,Double] = { case d if (d >= 0) => math.sqrt(d) } scala> root.isDefinedAt(-1) res0: Boolean = false scala> root(3) res1: Double = 1.7320508075688772 This is useful … Read more