runWith

trait PartialFunction[X, Y] {
  def runWith[U](g: (Y) => U): (X) => Boolean
}

runWith creates an anonymous function that applies this partial function and then g to an input value, if this partial function is defined for such value, and returns true.

For those values this partial function is not defined, the anonymous function just return false, without even applying g.