title: How does scala match on Arrays?
body: <p>looking through the Scala code, the convenient array creation syntax is achieved by adding an <code>apply</code> method to <code>object Array</code>.  At first, I thought this was achieved somehow through case classes because you can run the following, but this does not seem to be the case:</p>
  
  <pre><code>Array(1,2,3) match { case Array(a, b, c) =&gt; a + b + c }
  </code></pre>
  
  <p>I know that I also need to look at <code>WrappedArray</code> and all the superclasses, but I can't figure out how scala achieves this matching on Arrays (and I need to become more familiar with the scala collections class hierarchy).  It certainly doesn't work with a run-of-the-mill class.</p>
  
  <pre><code>scala&gt;  class A(val x: Int)
  scala&gt;  new A(4) match { case A(x) =&gt; x }
  &lt;console&gt;:9: error: not found: value A
                new A(4) match { case A(x) =&gt; x }
                                      ^
  &lt;console&gt;:9: error: not found: value x
                new A(4) match { case A(x) =&gt; x }
  </code></pre>
  
  <p>How do they get this to work with Array?</p>