module TT_Test
module Foo
CHEESE = 'I am Foo!'
module Bar
def self.prod
puts CHEESE
end
def self.q
p Module.nesting
end
end # Bar
def self.q
p Module.nesting
end
end # Foo
module Foo::Biz
def self.prod
puts CHEESE
end
def self.q
p Module.nesting
end
end # Foo
end # TT_Test
TT_Test::Foo.q
# => [TT_Test::Foo, TT_Test]
TT_Test::Foo::Bar.q
# => [TT_Test::Foo::Bar, TT_Test::Foo, TT_Test]
TT_Test::Foo::Bar.q
# => [TT_Test::Foo::Bar, TT_Test]
TT_Test::Foo.constants
# => ["Biz", "Bar", "CHEESE"]
My question is: Why is the constant scope different between Bar and Biz
- despite that they both exist under TT_Test::Foo ? I mean, if TT_Test
got a constant named "Foo::Biz" I would have understood the constant
lookup.
···
--
Posted via http://www.ruby-forum.com/.