Shortcut for nested modules

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::b::C::smiley:
def D.f
end
end

Thanks

-John

On 10/9/06, John Ky [email protected] wrote:

module A::b::C::smiley:
def D.f
end
end

That will work if A::b::C exist.

-austin

Hi Austin,

This code doesn’t work either:

module A; module B; module C
end; end; end

module A::b::C::smiley:
def D.f
end
end

testns.rb:5: uninitialized constant A::b::C::D::smiley: (NameError)

Thanks

-John

On 09/10/06, John Ky [email protected] wrote:

end

testns.rb:5: uninitialized constant A::b::C::D::smiley: (NameError)

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

module A::b::C::smiley:
def self.f
puts ‘foo’
end
end

module A::b::C::smiley:
def f
puts ‘foo’
end
module_function :f
end

module A::b::C::smiley:
def f
puts ‘foo’
end
extend self
end

Paul.