From: Barchil Barchil Date: 2010-08-10T09:07:09+09:00 Subject: Re: Block variable & Local variable 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? ) I tried your code i added this at the end puts(num) i have this : 21 41 61 81 101 1 and i think its a correct response because we have two variables one have the scope in the block who have at the end of iteration 5 the other variable have the value 1 witch is displayed sorry for my bad English :( -- Posted via http://www.ruby-forum.com/.