# Shortcut for nested modules

**URL:** <https://www.ruby-forum.com/t/shortcut-for-nested-modules/71501>\
**Category:** Ruby\
**Created:** [October 9, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/shortcut-for-nested-modules/71501 "2006-10-09T14:31:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Ky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@John\_Ky](https://www.ruby-forum.com/u/John_Ky)\
**Post date:** [October 9, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/shortcut-for-nested-modules/71501/1 "2006-10-09T14:31:28Z")

</div>

Hello,

Is there a short cut for:

> module A; module B; module C; module D  
> def D.f  
> end  
> end; end; end; end

The following doesn’t work for me:

> module A:🅱:C:😃  
> def D.f  
> end  
> end

Thanks

-John

---

<div class="post-metadata">

**Author:** ![John\_Ky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@John\_Ky](https://www.ruby-forum.com/u/John_Ky)\
**Post date:** [October 9, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/shortcut-for-nested-modules/71501/2 "2006-10-09T14:33:29Z")

</div>

On 10/9/06, John Ky [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > module A:🅱:C:😃  
> > def D.f  
> > end  
> > end

That will work if A:🅱:C exist.

-austin

---

<div class="post-metadata">

**Author:** ![John\_Ky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@John\_Ky](https://www.ruby-forum.com/u/John_Ky)\
**Post date:** [October 9, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/shortcut-for-nested-modules/71501/3 "2006-10-09T14:51:31Z")

</div>

Hi Austin,

This code doesn’t work either:

> module A; module B; module C  
> end; end; end
> 
> module A:🅱:C:😃  
> def D.f  
> end  
> end

testns.rb:5: uninitialized constant A:🅱:C::D:😃 (NameError)

Thanks

-John

---

<div class="post-metadata">

**Author:** ![John\_Ky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@John\_Ky](https://www.ruby-forum.com/u/John_Ky)\
**Post date:** [October 9, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/shortcut-for-nested-modules/71501/4 "2006-10-09T15:01:33Z")

</div>

On 09/10/06, John Ky [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > end
> 
> testns.rb:5: uninitialized constant A:🅱:C::D:😃 (NameError)

It’s the presence of D in the method name that’s the problem; any of  
these will work:

module A:🅱:C:😃  
def self.f  
puts ‘foo’  
end  
end

module A:🅱:C:😃  
def f  
puts ‘foo’  
end  
module\_function :f  
end

module A:🅱:C:😃  
def f  
puts ‘foo’  
end  
extend self  
end

Paul.
