7stud -- wrote in post #994396:
>
> In "The Well-Grounded Rubyist"  David Black explains that constants are
> like files in a file system, and depending on what "directory" you are
> currently in, it will determine the "path name" to the constant that you
> are interested in retrieving.  It seems that class_eval does not affect
> the path name to a constant.  But then I don't understand how
> class_eval'ing a string changes that.
>


Here is a blog post from 2007 asking the exact same question:

http://www.pgrs.net/2007/9/12/ruby-constants-have-weird-behavior-in-class_eval

As one person replied, constants are looked up by the parser, so their 
lexical scope determines the proper 'path' to the constant; while 
eval'ing a string happens in the 'dynamic scope' at runtime.

-- 
Posted via http://www.ruby-forum.com/.