From: Hugh Sasse Date: 2005-09-15T01:31:55+09:00 Subject: Re: Sets, uniqueness not unique. ---559023410-1663602767-1126715479=:29921 Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-1663602767-1126715479=:29921" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-1663602767-1126715479=:29921 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 15 Sep 2005, Mauricio Fern=E1ndez wrote: > Just one minor comment: > > batsman@tux-chan:~$ cat /tmp/fdsfdsdsd.rb > class Foo > FIELDS =3D %w[name stuff foo bar] > attr_reader(*FIELDS) That's rather nice :-) [...] > def eql2?(other) > # maybe add self.class::FIELDS =3D=3D other.class::FIELDS test plus re= scue NameError ? Good point. > self.class::FIELDS.each{|m| break false if self.send(m) !=3D other.sen= d(m) } && true Nice optimisation! I was having enough of a job keeping my head around inject to think of that! [...] > Rehearsal ----------------------------------------------------- > a.eql1?(a): true 1.520000 0.000000 1.520000 ( 1.658224) > a.eql2?(a): true 0.880000 0.000000 0.880000 ( 0.970675) [and similar] That makes quite a difference. Thank you. > > --=20 > Mauricio Fernandez > Hugh > ---559023410-1663602767-1126715479=:29921-- ---559023410-1663602767-1126715479=:29921--