I use the Scala operator match/caseto match the interface of this Java class. I want to be able to check if a class implements a combination of interfaces. The only way to get this to work is to use nested expressions match/casethat seem ugly.
Suppose I have a PersonImpl object that implements Person, Manager, and Investor. I want to see if PersonImpl implements both Manager and Investor. I should be able to do the following:
person match {
case person: (Manager, Investor) =>
case person: Manager =>
case person: Investor =>
case _ =>
}
case person: (Manager, Investor)just doesn't work. To make it work, I have to do the following, which seems ugly.
person match {
case person: Manager = {
person match {
case person: Investor =>
case _ =>
}
case person: Investor =>
case _ =>
}
It is just ugly. Any suggestions?
source
share