From: Bart Braem Date: 2006-09-13T00:55:41+09:00 Subject: Re: Maximum value of hash Farrel Lifson wrote: > On 12/09/06, Bart Braem wrote: >> A very simple question: what's the best way to get the maximum value of a >> hash? Currently I have something like: >> >> max = 0 >> hash.each_value do |value| >> if (value > max ) >> max = value >> end >> end >> >> But it does not feel ruby... Same question for sum, but I guess the >> answer will be similar? >> >> Bart >> >> > > hash.values.max > Thanks Farrel (and all others) for the fast replies. It didn't occur with me that the values array had this method of course... Bart