Skip to content

Instantly share code, notes, and snippets.

@rskelley9
Created September 2, 2013 08:26
Show Gist options
  • Save rskelley9/6410501 to your computer and use it in GitHub Desktop.
Save rskelley9/6410501 to your computer and use it in GitHub Desktop.
My Map method.
class Array
def my_map(&block)
self.each_index do |i|
yield (self[i] = block.call(self[i]))
end
end
end
a = [1,2,3,4]
puts a.my_map{|i| i -= 1} == a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment