On Thu, May 26, 2011 at 10:20 AM, Bala TS <bdeveloper01 / yahoo.com> 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.