My educated guess was to make things work like built-in types in .NET, namely that == should work as reference equality, where possible, and that Equals should work as equivalent equality, where possible. Consider the actual difference between == and Equals :
object myObj = new Integer(4); object myObj2 = new Integer(4);
This behavior, of course, is inconsistent and confusing, especially for new programmers, but it demonstrates the difference between comparative comparisons and value comparisons.
If you follow this MSDN guide, you follow the guide made by important classes such as string. Basically, if a comparison using == succeeds, the programmer knows that this comparison will always succeed if the links are not tied to new objects. The programmer need not worry that the contents of the objects are different because they will never be different:
//Mutable type var mutable1 = new Mutable(1); var mutable2 = mutable1; mutable1 == mutable2; //true mutable1.MutateToSomethingElse(56); mutable1 == mutable2; //still true, even after modification //This is consistent with the framework. (Because the references are the same, //reference and value equality are the same.) Consider if == were overloaded, //and there was a difference between reference and value equality: var mutable1 = new Mutable(1); var mutable2 = new Mutable(1); mutable1 == mutable2; //true mutable1.MutateToSomethingElse(56); mutable1 == mutable2; //oops
This boils down to the fact that there is no real technical reason for leadership - it just has to stay in line with the rest of the classes within.
Billy oneal
source share