Class: ReeArray::GroupBy
- Inherits:
-
Object
- Object
- ReeArray::GroupBy
- Includes:
- Ree::FnDSL
- Defined in:
- lib/ree_lib/packages/ree_array/package/ree_array/functions/group_by.rb
Instance Method Summary collapse
Instance Method Details
#call(list, &proc) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ree_lib/packages/ree_array/package/ree_array/functions/group_by.rb', line 11 def call(list, &proc) result = {} list.each do |element| key = yield(element) if result.has_key?(key) result[key] << element else result[key] = [element] end end result end |