title: Scala multiple type pattern matching
body: <p>I'm wondering how can I use multiple type pattern matching. I have:</p>
  
  <pre><code>abstract class MyAbstract
  
  case class MyFirst extends MyAbstract
  case class MySecond extends MyAbstract
  case class MyThird extends MyAbstract // shouldn't be matched and shouldn't call doSomething()
  
  val x: MyAbstract = MyFirst
  
  x match { 
   case a: MyFirst =&gt; doSomething()
   case b: MySecond =&gt; doSomething()
   case _ =&gt; doSomethingElse()
  }
  </code></pre>
  
  <p>So I'd like to write something like:</p>
  
  <pre><code>x match {
   case a @ (MyFirst | MySecond) =&gt; doSomething()
   case _ =&gt; doSomethingElse()
  }
  </code></pre>
  
  <p>I saw similar construction in some tutorial, but it gives me error:</p>
  
  <pre><code>pattern type is incompatible with expected type;
  [error]  found   : object MyFirst
  [error]  required: MyAbstract
  </code></pre>
  
  <p>So is there a way to define few different types in on case clause? I think it would make code prettier. As if I will have 5 of them, I will write same code 5 times (calling doSomething()).</p>
  
  <p>Thanks in advance!</p>