这是原始的SO问题的延续:使用“::”代替Ruby命名空间中的“module …”
在原始的SO问题中,介绍了以下场景,我仍然难以理解:
FOO = 123
module Foo
FOO = 555
end
module Foo
class Bar
def baz
puts FOO
end
end
end
class Foo::Bar
def glorf
puts FOO
end
end
puts Foo::Bar.new.baz # -> 555
puts Foo::Bar.new.glorf # -> 123
有人能解释一下为什么第一个调用返回555,第二个调用返回123吗?