I found myself writing something like this quite often:
a match { case `b` => // do stuff case _ => // do nothing }
Is there
The best I can come up with is this:
def matches[A](a:A)(f:PartialFunction[A, Unit]) = f.isDefinedAt(a) if (matches(a){case ... =>}) { //do stuff }
This won't win you any style points though.