I am wondering how I can use multiple template templates. I have:
abstract class MyAbstract case class MyFirst extends MyAbstract case class MySecond extends MyAbstract case class MyThird extends MyAbstract
So, I would like to write something like:
x match { case a @ (MyFirst | MySecond) => doSomething() case _ => doSomethingElse() }
I saw a similar construction in some kind of tutorial, but this gives me an error:
pattern type is incompatible with expected type; [error] found : object MyFirst [error] required: MyAbstract
So is there a way to define several different types in the case section? I think this will make the code more beautiful. As if I will have 5 of them, I will write the same code 5 times (doSomething () call).
Thanks in advance!
types scala pattern-matching
psisoyev Mar 27 '13 at 9:47 2013-03-27 09:47
source share