Marcelo Alvim
9/13/2006 12:03:00 AM
> Actually the Enumerable mixin module implements max, so any enumerable
> has it, and gives you the maximum element yielded by each
>
> (1..10).max #=> 10
> {'a' => 1, 'b' => 7}.max #=> ["b", 7]
> "abc\ndef".max #=> "def"
This is really sweet, but I think in this context it's worth noting that:
{'a' => 1, 'b' => 10, 'z' => 5}.max #=> ["z", 5]
As the thread is about hashes, it's nice to know that the #max method,
when applied to hashes, apparently yields the maximum value for the
keys, not for the values.
Alvim.