On Fri, Jun 11, 2010 at 6:47 PM, Robert Klemme
<shortcutter / googlemail.com> wrote:
> On 10.06.2010 18:27, Robert Dober wrote:
>>
>> On Thu, Jun 10, 2010 at 6:10 PM, Robert Klemme
>> <shortcutter / googlemail.com> wrote:
>>
>>> http://blog.rubybestpractices.com/posts/rklemme/018-Complete_Class.html
>>>
>>> http://blog.rubybestpractices.com/posts/rklemme/019-Complete_Numeric_Class.html
>>
>> I
>> You define #eql? and #hash for your convenience. So good, so bad. My
>> question simply was: Show my why *not* redefining #hash and #eql? will
>> cause problems, because that was Wilson's statement. I am still
>> waiting :(.
>
> The advice to implement #eql? and #hash really only makes sense if
> equivalence can reasonably be defined for a class and if instances of that
> class should be used as Hash keys or in Set.  ¨Βξοατ μεασερυιφαμεξγ> can be defined other than via identity (which is the default) then it is
> perfectly reasonable to not override both methods and go with the default
> implementation.
But that was *exactly* my point.

OP wanted to use Array#&, and Array#&, for a reason not too clear to
me, uses Object#eql? instead of Object#== I did discourage the
overloading of Object#eql? and Object#hash for *that purpose*.

If you want to change Hash then it is the right thing to do.
Now I might strongly disagree about if one should do that, but that is
rather OT and I would never have made such strong statements about
that issue.
However the technique you suggest is not to be put into non expert
hands as I tried to show with the memory leaking code above.

Cheers
Robert

>
> Kind regards
>
>  ¨Βοβες>
> --
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
>
>



-- 
The best way to predict the future is to invent it.
-- Alan Kay