Sha256: 6ac438f250fa9933a7185d479de35045eed512f08cb4f7efdf3f95b0b69b07d2
Contents?: true
Size: 287 Bytes
Versions: 9
Compression:
Stored size: 287 Bytes
Contents
module Enumerable # Returns a new array with the element at _index_ replaced by the result of # running _block_ on that element. def map_at(index, &block) fail IndexError if index < 0 || index >= size each_with_index.map { |e, i| i == index ? block.call(e) : e } end end
Version data entries
9 entries across 9 versions & 1 rubygems