From: Tanaka Akira Date: 2008-05-04T11:40:34+09:00 Subject: [ruby-dev:34585] module ::M in a module 以下のように、module M2 の中に module ::M と書いた時、 :: は無視されて M2::M が定義されるようです。 % ./ruby -ve ' module M def self.m() p :m end end module M2 module ::M p self p Module.nesting p self.m end end ' ruby 1.9.0 (2008-05-02 revision 16277) [i686-linux] M2::M [M2::M, M2] -e:9:in `': undefined method `m' for M2::M:Module (NoMethodError) from -e:6:in `' from -e:5:in `
' 1.8 では外側の M が参照されます。 % ruby-1.8 -ve ' module M def self.m() p :m end end module M2 module ::M p self p Module.nesting p self.m end end ' ruby 1.8.7 (2008-05-02 patchlevel 5000) [i686-linux] M [M, M2] :m nil :: を書いても意味がないというのは奇妙に思うんですが、意図的 でしょうか? -- [田中 哲][たなか あきら][Tanaka Akira]