From: "David A. Black" Date: 2003-12-03T23:21:37+09:00 Subject: Re: each_with_what_index? Hi -- On Wed, 3 Dec 2003, T. Onoma wrote: > Can you see the bug'a'boo in the following snippet? No, it looks OK to me. > 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. It's doing exactly what you ask: you've send the message "each_with_index" to an array (namely, a[1..-1]) and Ruby is acting accordingly. Did you want to do something more like: (1...a.size).each {|i| puts "#{a[i]}" } ? David -- David A. Black dblack@wobblini.net