From: Daniel Martin Date: 2007-01-17T12:33:39+09:00 Subject: Re: Can anyone try to solve this problems? "Sam Smoot" writes: > Here's my try at a Ruby 1.8 implementation of the Enumerable#max_by: Why build up a separate hash structure? def Enumerable.max_by ps = nil inject do |pmax, a| s = yield a if (ps == nil or s > ps) then ps = s a else pmax end end end -- s=%q( Daniel Martin -- martin@snowplow.org puts "s=%q(#{s})",s.map{|i|i}[1] ) puts "s=%q(#{s})",s.map{|i|i}[1]