On Wed, Jun 8, 2011 at 6:43 AM, Intransition <transfire / gmail.com> wrote:
>
>
> On Jun 8, 9:20am, John Feminella <jo... / bitsbuilder.com> wrote:
>> This is a pretty trivial error to generate. Just reference the
>> constant that doesn't exist:
>>
>> $ irb
>> ruby-1.9.2-p180 :001 > module X; module Foo; end; end
>> => nil
>> ruby-1.9.2-p180 :002 > X::Foo::X
>> NameError: uninitialized constant X::Foo::X
>
> Ah good point. I made an assumption. A qualifier then: X does exist.
> How about this must be as top of your solution.
>
>  module X; end

The top-level X (and the Foo underneath it) seems required to get the
error, so that doesn't make it harder. If you reference X::Foo::X
without X existing, you'll get
uninitialized constant Object::X (NameError)

If you reference X::Foo::X with just the part you have above, you'll
get uninitialized constant X::Foo (NameError)

The easiest way to get the error you ask about is
module X; module Foo; end; end
X::Foo::X

But I would guess that that probably isn't what you are looking for either.