- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
array equality
Sat, 2009-05-09, 13:49
One of the more interesting incongruities in the new lib:
scala> Array(1) == Array(1)
res0: Boolean = false
scala> Array(1) equals Array(1)
res1: Boolean = true
I haven't track that down, but I'm guessing the first goes straight to
java's equality for arrays and the second uses the equals override in
Iterable or similar. I see comments to the effect that array equality
semantics still needs to be decided. What are we thinking these days?
Maybe there's still time to do something about arrays for 2.8 - they
have quite a disproportionate standing in the bug database.
On Sat, May 9, 2009 at 2:49 PM, Paul Phillips wrote:
> One of the more interesting incongruities in the new lib:
>
> scala> Array(1) == Array(1)
> res0: Boolean = false
>
> scala> Array(1) equals Array(1)
> res1: Boolean = true
>
> I haven't track that down, but I'm guessing the first goes straight to
> java's equality for arrays and the second uses the equals override in
> Iterable or similar. I see comments to the effect that array equality
> semantics still needs to be decided. What are we thinking these days?
>
> Maybe there's still time to do something about arrays for 2.8 - they
> have quite a disproportionate standing in the bug database.
>
Yes, that's on the todo list. The intention is that Array(1) ==
Array(1) should return true. Something in erasure needs to be twiddled
to make that happen, I guess.
I am planning to have a look at this soon.
Cheers