I try to make Ruby loops using "each" like this:

# a is an array
a.each do  ...  end

But I always end up needing the array index in the body of the loop for
one reason or another.  Then I change it to:

i=0;
while i<a.length do
  ...
  i+=1
end

But this feels clunky and less Ruby-like.  Is there a way to access the
index in an "each" loop?  Is there a more elegant way to create an
indexed loop?
-- 
Posted via http://www.ruby-forum.com/.