I have a case from a library class and I want to override unapply
method to reduce the number of parameters I need to pass to
I would ditch the overloaded unapply and just use the following for the match:
a match {
case MyClass(x, _, _, _) => x // Result is: 1
case _ => "no"
}
EDIT :
If you really want to avoid the extra underscores, I think you'll need to look at something like:
a match {
case x:MyClass => x.a
case _ => "no"
}