I want to create an instance method of a type Array#my_map, and this method should work with the original method Array#map. I want to get the same result from a new method, as shown below:
arr = [1, 2, 3, 4]
arr.new_map_method do |x|
x + 1
end # => [2, 3, 4, 5]
arr.new_map_method(&:to_s) # => ["1", "2", "3", "4"]
source
share