From: "Marcel Molina Jr." Date: 2007-07-19T15:52:19+09:00 Subject: Re: Array : each_with_index On Thu, Jul 19, 2007 at 03:46:10PM +0900, Vin Raja wrote: > I have following lines > > m=['a','b','c'] > puts m.each_with_index{|v,i| i} > > which output in: > > >ruby try.rb > a > b > c > >Exit code: 0 irb(main):003:0> m.each_with_index{|v,i| i} => ["a", "b", "c"] irb(main):004:0> m.each_with_index{|v,i| p i} 0 1 2 => ["a", "b", "c"] The i variable in the block is indeed the index. But the result of the entire each_with_index expression is not the result of each block invocation, but the collection of all the array elements. marcel -- Marcel Molina Jr.