title: Scala Map pattern matching
body: <p>How to do pattern matching on a <code>Map</code> in Scala ?</p>
  
  <p>A (non working) attempt includes,</p>
  
  <pre><code>Map("a"-&gt;1, "b"-&gt;2, "c"-&gt;3) match {
    case Map(a,b,_*) =&gt; a
  }
  </code></pre>
  
  <p>which errs with</p>
  
  <pre><code>value Map is not a case class, nor does it have an unapply/unapplySeq member
                case Map(a,b,_*) =&gt; a
  </code></pre>
  
  <p>The error is indicative enough, yet how to enrich <code>Map</code> with an <code>unapply</code> method for pattern matching ?</p>
  
  <p>Many Thanks</p>
  
  <p><strong>Update</strong></p>
  
  <p>Following @Paul's comment, a neater use case may be like this,</p>
  
  <pre><code>Map("a"-&gt;1, "b"-&gt;2, "c"-&gt;3) match {
    case Map("b"-&gt;2,_*) =&gt; "222"
  }
  </code></pre>
  
  <p>namely, in this case, <em>if map contains key <code>b</code> that maps onto value <code>2</code></em>.</p>