Sha256: 2242a3723181a80a357e844129363166e938ab1f01e7c0d563a130ff0667eb69
Contents?: true
Size: 231 Bytes
Versions: 3
Compression:
Stored size: 231 Bytes
Contents
class Array def group_by h = Hash.new each do |element| key = yield(element) if h.has_key?(key) h[key] << element else h[key] = [element] end end h.map{|k,v| v} end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
jonuts-garb-0.2.4 | lib/extensions/array.rb |
vigetlabs-garb-0.2.4 | lib/extensions/array.rb |
garb-0.2.4 | lib/extensions/array.rb |