Skip to content

Instantly share code, notes, and snippets.

@sirkosi
Created March 13, 2015 17:03
Show Gist options
  • Save sirkosi/e2fcab631f4dbe328700 to your computer and use it in GitHub Desktop.
Save sirkosi/e2fcab631f4dbe328700 to your computer and use it in GitHub Desktop.
reverse each with original index.. don't ask..
class Array
def reverse_each_with_original_index
size_of_array = self.size
self.reverse.each_with_index do |object, i|
yield object, size_of_array - (i+1)
end
end
end
[:a, :b, :c].reverse_each_with_original_index{|object, index| puts "object: #{object} index: #{index}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment