Classes that are either case
or that implement the unapply()
method allow you to utilize pattern matching. However, in this case, all the patterns specified in the pattern matching are wildcard patterns. Either this is a mistake or you meant to simply match a specific type. In the latter's case, consider using the syntax v: Tpe
.
c match {
case C(_, _, _) => // matched!
// ...
}
// Resolution 1: Specify a non-wildcard pattern
c match {
case C(1, _, _) => // matched!
// ...
}
// Resolution 2: Match type
c match {
case v: C => // matched!
// ...
}