Hi -- On Fri, 30 May 2003, Seb Clediere wrote: > Dear Rubyists, > > I am sligthly surprised by this behaviour: > > if false > b = "" > else > 1.times { b = "b" } > end > > puts defined? b # => local-variable > puts b # => b > > 1.times do > if false > a = "" > else > 1.times { a = "a" } > end > puts defined? a # => local-variable(in-block) > puts a # => nil > end > > Any reason? I'm not sure what aspect of it is surprising you, but maybe it has to do with the fact that the assignment causes the variable to be defined (even if, at runtime, the assignment isn't executed): $ ruby -e 'if false; b = 1; end; p defined?(b)' "local-variable" Does that help explain it? David -- David Alan Black home: dblack / superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav