From: Alex Young Date: 2006-06-15T19:52:46+09:00 Subject: Re: Does each over an array bring a counter/index with it? Duane Morin wrote: > If I'm "each"ing over an array, is there a built-in way to get the > numeric index of the item that I'm on, or do I have to increment my own > counter variable? I saw each_with_index but that seems to be for Hash, > not Array. > irb(main):001:0> [5,10,15].each_with_index{|x,i| irb(main):002:1* puts "#{i}: #{x}" irb(main):003:1> } 0: 5 1: 10 2: 15 => [5, 10, 15] irb(main):004:0> -- Alex