From: Adam Prescott Date: 2011-05-26T19:05:55+09:00 Subject: Re: "Local variable within code blocks do not interfere with those outside the block" --20cf301cc3c275ba5c04a42af75b Content-Type: text/plain; charset=UTF-8 On Thu, May 26, 2011 at 10:20 AM, Bala TS wrote: > x.each do |r|{ > var = 10 > puts "#{var}"} > end > > => the result like this order > 10 > 10 > 10 > 10 > 10 > > But you gave > x.each do |r|{ > var = 10 > } > end > puts "#{var}" > In addition to the syntax errors, you will find this happens: NameError: undefined local variable or method `var' for main:Object `var` is local to the block. Because of that, it doesn't accurately explain the problem. --20cf301cc3c275ba5c04a42af75b--