考虑以下代码:
scala> case class Foo(s:String, t:String, r:String) {
| def == (f:Foo) = s == f.s && t == f.t
| }
defined class Foo
scala> val f1 = Foo("s", "t", "r")
f1: Foo = Foo(s,t,r)
scala> val f2 = Foo("s", "t", "r1")
f2: Foo = Foo(s,t,r1)
scala> f1 == f2
res24: Boolean = true
scala> Array(f1) contains (f2)
res25: Boolean = false
我的印象是上面定义的contains
用途。==
我误会了吗?
版本:Scala-2-10-2