From: Eugen Ciur Date: 2010-08-03T17:41:13+09:00 Subject: Re: Block variable & Local variable |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 On 08/03/2010 11:19 AM, Amir Ebrahimifard wrote: > Hi > What does happen for "num" variable in this code : > > array = [1,2,3,4,5] > x = 1 > num = 1 > array.each { |num| puts num*20 + x } > > ( after this code when I type "puts num , ruby return 5 ! why? ) >