From: Dick Davies Date: 2006-06-15T19:57:11+09:00 Subject: Re: Does each over an array bring a counter/index with it? It's actually defined in Enumerable, which is mixed into Array and Hash: a = %w(eeny meeny miney mo) a.each_with_index { |thing,number| puts "#{number}: #{thing}" } produces: 0: eeny 1: meeny 2: miney 3: mo On 15/06/06, 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. > > -- > Posted via http://www.ruby-forum.com/. > > -- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/