Re: equals in terms of equalHashValues?
On Thu, Jun 11, 2009 at 01:03:59PM -0700, Landei wrote:
> This is not only a theoretical question, as Range already *uses* an
> equals method as described. So I wrote a little test to count the
> clashes for Range (please correct me if I didn't understood the
> algorithm correctly):
For sure that trait is highly experimental (I just have way too much
code in local branches and am attempting to work some of it into trunk.)
That said, I'm not sure what you think is happening in there, but who
cares if unequal ranges have equal hashcodes? Unequal objects have equal
hashcodes all the time.
Equality is defined in terms of the list of values you provide. This is
exactly like it's done in case classes and oh roughly everything.
// you define this
protected def hashValues: List[Any]
And then equals is defined as: hashValues == other.hashValues.
Also, that isn't Range, it's GenericRange.
--
Paul Phillips | It is hard to believe that a man is
In Theory | telling the truth when you know that you
Empiricist | would lie if you were in his place.
slap pi uphill! | -- H. L. Mencken