From: 7stud -- Date: 2011-04-22T08:14:47+09:00 Subject: Re: class_eval doesn't find const_missing Stephen Prater wrote in post #994391: > http://stackoverflow.com/questions/3015947/ruby-how-does-constant-lookup-work-in-instance-eval-class-eval > > Const lookup varies between 1.8, 1.9.1, and 1.9.2. > > Basically, constants are lexically scoped. > > You can use "const_get" I believe to lookup your constant in the > current binding rather than in the lexical scope. > That works for me in ruby 1.9.2: DummyClass.class_eval do puts const_get(:NAME) end --output:-- dummy constant That makes sense because the call is really: puts self.const_get(:NAME) and because self is equal to DummyClass, that is equivalent to: puts DummyClass.const_get(:NAME) which like class_eval'ing a string does the lookup in the "directory" DummyClass. -- Posted via http://www.ruby-forum.com/.