title: Scala: Contains in mutable and immutable sets
body: <p>I've discovered a strange behavior for mutable sets which I cannot understand:</p>
  
  <p>I have a object which I want to add to a set. The equals method for the class is overridden. When I add two different objects to the set, which produces the same output for equals method, I get a different behavior between mutable and immutable sets for the contains method.</p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>class Test(text:String){
    override def equals(obj:Any) = obj match {
      case t: Test =&gt; if (t.text == this.text) true else false
      case _ =&gt; false
    }
    override def toString = text
  }
  
  val mutableSet:scala.collection.mutable.Set[Test] = scala.collection.mutable.Set.empty
  mutableSet += new Test("test")
  println(mutableSet)
  println(mutableSet.contains(new Test("test")))
  
  val immutableSet:scala.collection.immutable.Set[Test] = scala.collection.immutable.Set.empty
  immutableSet += new Test("test")
  println(immutableSet)
  println(immutableSet.contains(new Test("test")))
  </code></pre>
  
  <p>This produces as output:</p>
  
  <pre><code>Set(test)
  false
  Set(test)
  true
  </code></pre>
  
  <p>In my opinion both calls of contains should produce the same output (true). </p>
  
  <p>Could anybody help me to understand the difference here or is this a bug in the scala immutable set implementation? By the way, I use scala 2.8.1.final</p>
  
  <p>Thanks.</p>