module Enumerable
Public Instance Methods
map_at(index, &block)
click to toggle source
Returns a new array with the element at index replaced by the result of running block on that element.
# File lib/metamorpher/support/map_at.rb, line 4 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