Sha256: 3428a4bb130e2acf9e2e59e7951bc1def6be25e09a69241f67cb0b7f5b42e804
Contents?: true
Size: 374 Bytes
Versions: 13
Compression:
Stored size: 374 Bytes
Contents
module Enumerable # Same as #collect but with an iteration counter. # # a = [1,2,3].collect_with_index { |e,i| e*i } # a #=> [0,2,6] # # CREDIT: Gavin Sinclair def map_with_index r = [] each_with_index do |e, i| r << yield(e, i) end r end # Alias for map_with_index. alias_method :collect_with_index, :map_with_index end
Version data entries
13 entries across 12 versions & 2 rubygems