Method: Enumerable#group_by
- Defined in:
- lib/ole/support.rb
#group_by ⇒ Object
1.9 backport
40 41 42 43 44 |
# File 'lib/ole/support.rb', line 40 def group_by hash = Hash.new { |h, key| h[key] = [] } each { |item| hash[yield(item)] << item } hash end |