Is it a rule that unapply will always return an Option?
问题 I tried to create an unapply method to use in pattern matching, and I tried to make it return something different than Option , however, Eclipse shows that as an error. Is it a rule that unapply must return an Option[T] ? EDIT: here's the code I'm trying to use. I switched the code from the previous section so that unapply returns a Boolean import java.util.regex._ object NumberMatcher { def apply(x:String):Boolean = { val pat = Pattern.compile("\\d+") val matcher = pat.matcher(x) return