From: Hugh Sasse Date: 2005-09-15T01:54:16+09:00 Subject: Re: Sets, uniqueness not unique. On Thu, 15 Sep 2005, Christian Neukirchen wrote: > This seems to be the canonical way to define compund hashes: > > class Student > def hash > [@forename, @surname, @birth_dt, @picture, @coll_status].hash > end > end That does seem to preserve the properties I need for strings, and is probably cheaper than MD5sums. > [...] > > Set uses a Hash to store the objects. > > That said, I think it would be nice to have something along this in > the stdlib: > > class Student > equal_compares :@forename, :@surname, :@birth_dt, :@picture, :@coll_status > end > > Above call should result in appropriate definitions of ==, eql? and I don't know how it could know how to create the different definitions correctly given a completely open spec as to what the vars are. > hash. (Something like "ordered_by" would be pretty useful too.) I think that could be tricky too. > Thank you. Hugh