From: Yukihiro Matsumoto Date: 2006-02-27T08:48:22+09:00 Subject: Re: Scope of constants in instance_eval Hi, In message "Re: Scope of constants in instance_eval" on Mon, 27 Feb 2006 02:23:34 +0900, "Phrogz" writes: |class Foo | BAR = 1 | def initialize( &block ) | instance_eval &block | end | def bork | puts "bork: self is #{self}" | puts "bork: BAR is #{BAR}!" | end |end | |Foo.new{ | bork | puts "block: self is #{self}" | puts "block: BAR is #{BAR}!" |} | |#=> bork: self is # |#=> bork: BAR is 1! |#=> block: self is # |#=> NameError: uninitialized constant BAR In 1.8, constant uses lexical look-up, even within the block given to instance_eval(). We changed this behavior in 1.9 to simplify things. matz.