Why does `Array(0,1,2) == Array(0,1,2)` not return the expected result?
- by soc
As far as I understand, Scala's == defines the natural equality of two objects.
I expected that Array(0,1,2) == Array(0,1,2) compares the natural equality e. g. checks if all elements of the array return true when compared with the corresponding elements of the other array.
People told me that Scala's Array is just a Java [] which only compares identity. But Scala's String is also just a Java String but Scala overrides equals to compare natural equality.
I wonder why Array's equals method was not overridden, too.
Thank you for your thoughts!