From: Pat Maddox Date: 2006-01-21T00:06:12+09:00 Subject: Re: Array#each - getting each element and the index On 1/20/06, James Edward Gray II wrote: > On Jan 20, 2006, at 8:08 AM, Pat Maddox wrote: > > > Is there a way to get each element of an array, as well the index of > > that element? > > You bet. > > > Something like > > a = %w[foo bar] > > a.each { |val, index| .... } # val => 'foo', index => 0 > > a.each_with_index ... > > James Edward Gray II > > Perfect, thanks Is this using some idiom (e.g. attaching _with_index) that I don't know about? I didn't see that method in the Array rdoc.