Sha256: 5eccc65875ca4bfd7c666cb3831cc2ad97521274f35e1595351d6d565ce44a2f
Contents?: true
Size: 401 Bytes
Versions: 109
Compression:
Stored size: 401 Bytes
Contents
# frozen_string_literal: true class ReeArray::GroupBy include Ree::FnDSL fn :group_by contract( ArrayOf[Any], Block => HashOf[Any, ArrayOf[Any]] ) 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 end
Version data entries
109 entries across 109 versions & 1 rubygems