swdyh

uniq_by

2007-05-02 08:45:29
def uniq_by #:yield:
  h = {}; inject([]) {|a,x| h[yield(x)] ||= a << x}
end

http://facets.rubyforge.org/src/doc/rdoc/core/classes/Enumerable.html#M001321