title: override equals() method of Pair
body: <p>This question was previously asked in scala-user mailing-list without a confirmed answer. </p>
  
  <pre><code>scala&gt; val T = new Pair(1, 2){
  override def equals(obj:Any) = obj.isInstanceOf[(Int, Int)] &amp;&amp; obj.asInstanceOf[(Int, Int)]._1 == this._1}
             }
  
  T: (Int, Int) = (1,2)
  
  scala&gt; T match {
          case (1, 1) =&gt; println("matched")
          case _ =&gt; println("not matched")
     }
  
  not matched
  
  
  scala&gt; (1, 1) match {
                case T =&gt; println("matched")
                case _ =&gt; println("not matched")
            }
  
  not matched
  
  scala&gt; T == (1, 1)
  res15: Boolean = true
  </code></pre>
  
  <p>I thought a constant(val) pattern matching result depends on the return value of "equals", but the results show that it is not the case, then what is the criteria?</p>
  
  <p>Someone had suggested that <code>case (1, 1) =&gt;</code> is an extractor pattern and uses <code>Tuple2.unapply</code> instead. so I tried these:</p>
  
  <pre><code>scala&gt; Pair.unapply(T)
  res1: Option[(Int, Int)] = Some((1,2))
  
  scala&gt; Pair.unapply(T).get == (1, 1)
  res2: Boolean = true
  </code></pre>
  
  <p>Can anyone please explain why <code>==</code> get true but I cannot make them match?</p>