From: Guglielmo Fachini Date: 2010-08-03T17:53:05+09:00 Subject: Re: Block variable & Local variable Eugen Ciur wrote: > |num| inside block iterates through array's items. > Last item in array is 5, thus |num| value will be the one from last > iteration of 'each' method. > It is better to rename |num| to something else, |item| for example. > ----- > Eugen I've tried it in my machine and the output is 1... C:\Users\Guglielmo>ruby -v ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32] C:\Users\Guglielmo>ruby array = [1,2,3,4,5] x = 1 num = 1 array.each { |num| puts num*20 + x } puts num ^D 21 41 61 81 101 1 -- Posted via http://www.ruby-forum.com/.