In C#, why Equals() method on arrays only compare their references, not their actual content

Although Microsoft’s Framework classes are unfortunately a bit inconsistent with regard to what Object.Equals(Object) means, in general X.Equals(Y) will only be true if replacing arbitrary references to X with references to Y, and/or vice versa, would not be expected to alter the semantics of the objects in question. For example, if X is a String … Read more

Strange behaviour of the Array type with `==` operator

Because the definition of “equals” for Arrays is that they refer to the same array. This is consistent with Java’s array equality, using Object.Equals, so it compares references. If you want to check pairwise elements, then use sameElements Array(‘a’,’b’).sameElements(Array(‘a’,’b’)) or deepEquals, which has been deprecated in 2.8, so instead use: Array(‘a’,’b’).deep.equals(Array(‘a’,’b’).deep) There’s a good Nabble … Read more