From: "Gray, Jeff" Date: 2002-06-06T04:22:19+09:00 Subject: RE: Is this a bug in the defined? operator? > From: matz@ruby-lang.org [mailto:matz@ruby-lang.org] > Sent: Tuesday, June 04, 2002 7:39 PM > To: ruby-talk@ruby-lang.org > Subject: Re: Is this a bug in the defined? operator? > > In message "Is this a bug in the defined? operator?" > on 02/06/05, "Gray, Jeff" writes: > > |The behavior of the following code seems like a bug to me: > > No, local variable scope is *static*, not dynamic, so that: Aha. > I think what you want is > > foo = false > [1, 2, 3, 4].each { |x| > if foo > puts "foo is set" > else > puts "foo not set" > foo = true > end > } > > matz. Actually, what I was going for in the first place that led me to this observation was a quick-n-dirty three-state "boolean": true, false, and unknown. It seemed at the time that 'defined?' would get me the equivalent of the unknown state. Thanks for the quick response! - jeff