From: George Ogata Date: 2006-02-27T08:08:36+09:00 Subject: Re: Scope of constants in instance_eval George Ogata writes: > "Phrogz" writes: > >> Evaling as a string works. (Constant is resolved.) > > But only in 1.9, if I understand you correctly. Sorry, I see this follows on from Jim's post. Here's a silly idea that might make your other syntax work. $bindings = [] def Object.const_missing(name) if $bindings.empty? raise NameError, "uninitialized constant #{name}" end binding = $bindings.pop eval(name.to_s, binding) ensure $bindings.push(binding) end class C def initialize &b $bindings.push binding instance_eval(&b) ensure $bindings.pop end X = 2 end C.new{puts X}