Proposal: Sameness operators
mthornton at optrak.co.uk
Thu Apr 2 10:42:21 PDT 2009
Reinier Zwitserloot wrote:
> The argument that .compareTo should not be used because it isn't
> entirely congruent with either the meaning of .equals() or the
> meanings of all the comparison operators (from == to <) on the
> primitives, just doesn't hold water, for this simple reason:
I merely meant that if you want to have a set of comparison operators
with some of them based on compareTo, then they all must be based on
compareTo --- you can't use equals (or ==) for the equality comparisons.
Therefore you have three sets of operations
==, System.identityHashCode(), plus for some types <, <=, >, >=
All these need to remain clearly distinct because their existing
behaviour is not always compatible.
More information about the coin-dev