Ruby Forum Ruby-dev > module ::M in a module

Posted by Tanaka Akira (Guest)
on 04.05.2008 04:40
(Received via mailing list)
$B0J2<$N$h$&$K!"(Bmodule M2 $B$NCf$K(B module ::M $B$H=q$$$?;~!"(B
:: $B$OL5;k$5$l$F(B M2::M $B$,Dj5A$5$l$k$h$&$G$9!#(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 method `m' for M2::M:Module 
(NoMethodError)
        from -e:6:in `<module:M2>'
        from -e:5:in `<main>'

1.8 $B$G$O30B&$N(B M $B$,;2>H$5$l$^$9!#(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

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