Thread: Ruby Snippets
View Single Post
Old Apr 10th, 2006, 3:37 AM   #11
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
This probably does the same thing:
class Array
    def max_by(&block)
        max { |a, b| block.call(a) <=> block.call(b) }
    end
end
Arevos is offline   Reply With Quote