Sha256: 806d63e53dbb741c339c21d9d17a81dda580f10babc1b01a3d0e223636e3920d

Contents?: true

Size: 189 Bytes

Versions: 8

Compression:

Stored size: 189 Bytes

Contents

#taken from rails, will be in Ruby 1.9
module Enumerable
  def group_by
    inject({}) do |groups, element|
      (groups[yield(element)] ||= []) << element
      groups
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mspire-0.4.9 lib/group_by.rb
mspire-0.3.0 lib/group_by.rb
mspire-0.3.9 lib/group_by.rb
mspire-0.3.1 lib/group_by.rb
mspire-0.4.4 lib/group_by.rb
mspire-0.4.2 lib/group_by.rb
mspire-0.4.5 lib/group_by.rb
mspire-0.4.7 lib/group_by.rb