In message "[ruby-talk:00351] local variables"
    on 99/05/27, Pros Yeboah <yeboah / tu-harburg.de> writes:

|Can someone  please explain it ,why I get this:
|ruby -e'i=3;def foo;p defined?(i);end;foo'  #==>nil
|ruby -e'i=3;1.times{p defined?(i)}             #==>"local-variable"

Because a function definition introduces new scope, so you have a
clean local variable space in foo.  That's the reason you receive nil
from defined?(i) in foo.  Scopes by function do not nest, i.e. you
cannot access local variables in the outer scope.

On the other hand, even though blocks introduces scopes, they nest.
You can access local variables in the outer scope within the blocks.

                                                matz.