From: kinfe0@... (Kinfe) Date: 2002-01-08T23:40:02+09:00 Subject: Re: move index back ward in list.each do {} Michael Kelly wrote in message news:<8ebh3uo2vf863n1nevdup03ator64rd8l6@4ax.com>... > On 5 Jan 2002 16:14:38 -0800, kinfe0@netscape.net (Kinfe) wrote: > > > At this point I would like to advance the next index in a.each but > >remain in b.each, another word, b[4] will not become b[5] after the > >a[had advance], how can I do ? > > To alter indexes inside a loop I think generally > it's better to use a while or some other simple > loop with counters instead of trying to alter > the behavior of an iterator. A while loop > like the one below with a few edits should > do what you need > > i = 0 > j = 0 > while (i < a.length) and (j < b.length) > if a[i] == b[j] # or some other condition > i += 1 # only advance one index > next > end > i += 1 > j += 1 > #do something on each loop > end > > > Mike Thanks all, I found 'array.each_index' and it works. Kinfe.