Sha256: 73a11b2d7e7e2f59cebf7be9cc326195d7cd146fab15da9b2017b77abcb8e25e
Contents?: true
Size: 319 Bytes
Versions: 4
Compression:
Stored size: 319 Bytes
Contents
# for versions of ruby < 1.8.7 module Enumerable def index_by inject({}) do |accum, elem| key = yield(elem) accum[key] ||= [] accum[key] << elem accum end end def group_by #:yield: #h = k = e = nil r = Hash.new each{ |e| (r[yield(e)] ||= []) << e } r end end
Version data entries
4 entries across 4 versions & 1 rubygems