From: "Brian Schröder" Date: 2005-05-24T17:42:12+09:00 Subject: Re: loop over array with indices On 23/05/05, Berger, Daniel wrote: > > -----Original Message----- > > From: Johannes Ahlmann [mailto:softpro@gmx.net] > > Sent: Monday, May 23, 2005 3:15 PM > > To: ruby-talk ML > > Subject: loop over array with indices > > > > > > hi, > > > > i have the recurring problem that i want to loop over an > > array with each/collect/... but (as an afterthought) need the > > index of the current element. > > See Enumerable#each_with_index. > > Regards, > > Dan > > And define yourself map_with_index, inject_with_index etc. where needed. I always miss them. best regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/