Sha256: 709d64262fa4f4fb9568b5648826ebb121a6b5718563a1a4fbe69c3f6a5d8cef

Contents?: true

Size: 148 Bytes

Versions: 17

Compression:

Stored size: 148 Bytes

Contents

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spruz-0.2.13 lib/spruz/uniq_by.rb
spruz-0.2.12 lib/spruz/uniq_by.rb
spruz-0.2.11 lib/spruz/uniq_by.rb
spruz-0.2.10 lib/spruz/uniq_by.rb
spruz-0.2.9 lib/spruz/uniq_by.rb
spruz-0.2.8 lib/spruz/uniq_by.rb
spruz-0.2.7 lib/spruz/uniq_by.rb
spruz-0.2.6 lib/spruz/uniq_by.rb
spruz-0.2.5 lib/spruz/uniq_by.rb
spruz-0.2.2 lib/spruz/uniq_by.rb
spruz-0.2.1 lib/spruz/uniq_by.rb
spruz-0.2.0 lib/spruz/uniq_by.rb
spruz-0.1.5 lib/spruz/uniq_by.rb
spruz-0.1.3 lib/spruz/uniq_by.rb
spruz-0.1.2 lib/spruz/uniq_by.rb
spruz-0.1.1 lib/spruz/uniq_by.rb
spruz-0.1.0 lib/spruz/uniq_by.rb