class Array
Public Instance Methods
group_by(&blk)
click to toggle source
# File lib/core_ext/array.rb, line 2 def group_by(&blk) Hash.new { |h,k| h[k] = [] }.tap do |hash| each do |element| hash[blk.call(element)] << element end end end