Re-opened nested module anomaly in Ruby
Why does re-opening a nested module give different results depending on the syntax used? For example, this works fine: module A module E end end module A module E def E.e end end end But this: module A module E end end module A::E def E.e end end gives the error: reopen.rb:6:in `<module:E>': uninitialized constant A::E::E (NameError) from reopen.rb:5:in `<main>' (Before someone points this out, a workaround is to use self instead of the module name when defining E.e, but that's not really the point of this post.) The module keyword sets a namespace context that is checked for references to