From: why the lucky stiff Date: 2004-04-13T10:26:44+09:00 Subject: Re: Two different results for Module.nesting Brian Marick wrote: > Consider this: > > module M1 > module M2 > class C > puts Module.nesting.inspect > end > end > end > > It produces [M1::M2::C, M1::M2, M1], which I expected. > > Now try this: > > M1::M2::C.class_eval("Module.nesting") > > It produces [M1::M2::C], which I did not expect. Why the difference? > Thanks. It's returning the proper nesting. But as you haven't opened each of the Modules individually to reach the C const, Module::nesting isn't returning them each individual. Let's illustrate: module M1::M2 class C puts Module.nesting.inspect end end #=> [M1::M2::C, M1::M2] _why