I want to a pattern is matching or not.
I end up writing a horrid piece of code like this
val isMatch = something match {
case Some(Complex(Pattern(matching) :: Nil)) => true
case _ => false
}
This looks to me exactly like doing this
val isConditionTrue = if (someCondition) {
true
} else {
false
}
Which is an eye sore and can be reduced of course to this
val isConditionTrue = someCondition
Or simply
someCondition
But I couldn't find a way (perhaps I'm missing something silly) to do that with a pattern matching (again, not talking about Regex here, just good old Scala pattern matching
Is there something to do here with a Partial Function / isDefinedAt etc? Is there any utility method to check e.g. something like
isPatternMatching(object, Pattern)