From: matz@... (Yukihiro Matsumoto) Date: 2002-06-05T11:38:37+09:00 Subject: Re: Is this a bug in the defined? operator? Hi, 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: |[1, 2, 3, 4].each { |x| | if defined? foo | puts "foo is defined" # no "foo" defined here | else # even in the second loop | puts "foo not defined" | foo = true # "foo" defined here | end |} 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.