Module: Tins::UniqBy

Defined in:
lib/tins/uniq_by.rb

Instance Method Summary collapse

Instance Method Details

#uniq_by(&b) ⇒ Object



3
4
5
6
# File 'lib/tins/uniq_by.rb', line 3

def uniq_by(&b)
  b ||= lambda { |x| x }
  inject({}) { |h, e| h[b[e]] ||= e; h }.values
end