From: Gavin Sinclair Date: 2003-12-03T20:23:36+09:00 Subject: Re: each_with_what_index? On Wednesday, December 3, 2003, 10:01:38 PM, T. wrote: > Can you see the bug'a'boo in the following snippet? > a[1..-1].each_with_index do |t,i| > puts "#{t} => #{a[i]}" > # ... > end > Now, I understand why it happens, but nonethess I spent a good while tracking > it down (in a slightly more complex version). I guess that's just the way it > has to be, but it is quite unintuitive. Bugs can be like that sometimes, but there's absolutely nothing unintutive about that, unless you want Ruby to start guessing what you really mean all the time :) Maybe this is better for you? a.each_with_index do |t,i| next if i == 0 puts "#{t} => #{a[i]}" # ... end Gavin