I want to use a for-each and a counter:
i=0 for blah in blahs puts i.to_s + \" \" + blah i+=1 end
Is there a better way to do it?>
If you don't have the new version of each_with_index, you can use the zip method to pair indexes with elements:
each_with_index
blahs = %w{one two three four five} puts (1..blahs.length).zip(blahs).map{|pair|'%s %s' % pair}
which produces:
1 one 2 two 3 three 4 four 5 five