From: nobu@... Date: 2006-07-30T17:16:35+09:00 Subject: Re: Inconsistency in scoping during module_eval? Hi, At Sun, 30 Jul 2006 15:31:27 +0900, Charles O Nutter wrote in [ruby-core:08441]: > Why is it that bar is correctly defined under the class Foo, but BAZ gets > defined at the top level? Is there a reason for this inconsistency? Your code is equivalent to: > class Foo > end > > BAZ = 1 > > p defined?(bar) => nil > p defined?(BAZ) => "constant" > p defined?(Foo::BAZ) => "constant" And if you don't use defined?, you'll see a warning like as: warning: toplevel constant BAZ referenced by Foo::BAZ -- Nobu Nakada