title: Scala implicit type conversion and ==
body: <p>Can anyone enlighten me as to why implicit type conversion does not work with <code>==</code>?</p>
  
  <p>Example:  </p>
  
  <pre><code>class BitArray(l: Int, v: Long) {  
      val length = l  
      var value = v  
      def ==(that: BitArray) = value == that.value  
      def ==(integer: Long) = value == integer  
      def +(that: BitArray) = new BitArray(length,value+that.value )  
      def +(integer: Long) = new BitArray(length,value+integer )  
  //...  
  }  
  object BitArray{
          implicit def longToBitArray(x : Long) = new BitArray(64,x)  
          def apply(v: Long) :BitArray = apply(64,v)  
  }
  </code></pre>
  
  <p>Now I can do:</p>
  
  <pre><code>scala&gt; BitArray(5) + 5  
  res13: BitArray = 00000000000000000000000000001010  
  scala&gt; 5 + BitArray(5)   
  res14: BitArray = 00000000000000000000000000001010  
  scala&gt; BitArray(5) == 5  
  res15: Boolean = true  
  scala&gt; BitArray(5) == 6  
  res16: Boolean = false  
  </code></pre>
  
  <p>BUT:</p>
  
  <pre><code>scala&gt; 5 == BitArray(5)  
  &lt;console&gt;:11: warning: comparing values of types Int and BitArray using `==' will   
  always yield false  
         5 == BitArray(5)  
           ^  
  res17: Boolean = false  
  </code></pre>