def enumerate(arr):
(0..arr.length - 1).to_a.zip(arr)
Is something built in for this? It doesn't need to have it's members immutable, it just needs to be in the standard library. I don't want to be the guy who subclasses the Array class to add a Python feature to a project.
Does it have a different name in Ruby?
%w(a b c).enumerate
=> [[0, "a"], [1, "b"], [2, "c"], [3, "d"]]
a = 'do re mi fa'.split()
might be closer to the Ruby version – Thirzi