I normally do [\'abc\', \'defg\'].max{|a, b| a.length <=> b.length}, but this seems like a lot of extra typing to compare the results of the same method o
[\'abc\', \'defg\'].max{|a, b| a.length <=> b.length}
For an array of Hashes:
roomies = [{:name => "Habib", :age => 24}, {:name => "Tyler", :age => 25}] roomies.max_by{|a| a[:age]}[:age] => 25
This is more concise:
['abc', 'defg'].max_by{|x| x.length }
['abcd', 'def'].max_by &:length