From: Mathieu Bouchard Date: 2001-10-10T04:45:45+09:00 Subject: [ruby-talk:22340] Re: blocks with min and max On Wed, 10 Oct 2001, Yukihiro Matsumoto wrote: > Enumerable#min and #max already work like the former, i.e. > largest = collection.max {|obj1, obj2| obj1.attrib <=> obj2.attrib} > But I now think I should have chosen the latter. > largest = collection.max {|obj| obj.attrib} Then how would this translate to the latter way? largest = collection.max {|obj1, obj2| r = obj1.foo <=> obj2.foo r = nil if r == 0 r || (obj1.bar <=> obj2.bar) } ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju