M
Martin DeMello
Robert Klemme said:module Enumerable
def uniq_by
h = {}; inject([]) {|a,x| h[yield(x)] ||= a << x}
end
end
=> [2, 7, 9]
Beautiful about this version is that it does not need the "; h" at the end
of the inject block and no ".values", too...
Very nice indeed.
martin