module NgaExtensions::Array
Public Instance Methods
group_into(&block)
click to toggle source
# File lib/nga_extensions/array.rb, line 3 def group_into(&block) # send a block that returns a symbol and receive a hash self.inject({}) do |hash,v| k = block.call(v) array = hash[k] || [] array << v hash[k] = array hash end end