Module ::M in a module

e$B0J2<$N$h$&$K!"e(Bmodule M2 e$B$NCf$Ke(B module ::M e$B$H=q$$$?;~!"e(B
:: e$B$OL5;k$5$l$Fe(B M2::M e$B$,Dj5A$5$l$k$h$&$G$9!#e(B

% ./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 <module:M>': undefined methodm’ for M2::m:Module
(NoMethodError)
from -e:6:in <module:M2>' from -e:5:in

1.8 e$B$G$O30B&$Ne(B M e$B$,;2>H$5$l$^$9!#e(B

% 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

:: e$B$r=q$$$F$b0UL#$,$J$$$H$$$&$N$O4qL/$K;W$&$s$G$9$,!"0U?^E*e(B
e$B$G$7$g$&$+e(B?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs