From: Nikolai Weibull Date: 2011-12-30T19:09:42+09:00 Subject: Re: What’s the standard way of implementing #hash for value objects in Ruby? On Fri, Dec 30, 2011 at 10:44, Josh Cheek wrote: > On Fri, Dec 30, 2011 at 3:09 AM, Nikolai Weibull wrote: >> It would make implementing #hash, which you should/must do >> if you implement #==, trivial, as there’s then only one way to do so. > Delegating to the most relevant attribute still seems more trivial. Trivial – perhaps. Wrong – most definitely. That you don’t seem to understand this is what tells me that you don’t understand how #hash should be implemented. > I suppose one reason I take this view could be that the only viable > scenarios I can think of for making some arbitrary object into a hash key > are for sets and Array#uniq. For me, these scenarios are exceedingly rare, > and have always been trivially replaced with alternative keys. How about having them as keys in an actual Hash (which is how Sets and Array#uniq are currently implemented)?