Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
I don't know why!!
Kyung won Cheon
8/8/2008 1:58:00 AM
-- test1.rb --
module M
module MM
class C
end
class D < MM::C
end
class E < MM::C; puts self; end
end
end
# => M::MM::E
-- test2.rb --
module M
module MM
class C
end
class D < MM::C
end
#class E < MM::C; puts self; end
end
end
M::MM.module_eval("class E < MM::C; puts self; end")
# => uninitialized constant M::MM::MM (NameError)
-- test3.rb --
module M
module MM
class C
end
class D < MM::C
end
#class E < MM::C; puts self; end
end
end
M::MM.module_eval("class E < C; puts self; end")
# => M::MM::E
###################
# test2.rb ???
###################
--
Posted via
http://www.ruby-...
.
1 Answer
TPReal
8/9/2008 10:05:00 PM
0
On Aug 8, 3:57 am, Kyung won Cheon <kdrea...@gmerce.co.kr> wrote:
> -- test1.rb --
>
> module M
> module MM
> class C
> end
>
> class D < MM::C
> end
>
> class E < MM::C; puts self; end
> end
> end
>
> # => M::MM::E
>
> -- test2.rb --
>
> module M
> module MM
> class C
> end
>
> class D < MM::C
> end
>
> #class E < MM::C; puts self; end
> end
> end
>
> M::MM.module_eval("class E < MM::C; puts self; end")
>
> # => uninitialized constant M::MM::MM (NameError)
>
> -- test3.rb --
>
> module M
> module MM
> class C
> end
>
> class D < MM::C
> end
>
> #class E < MM::C; puts self; end
> end
> end
>
> M::MM.module_eval("class E < C; puts self; end")
>
> # => M::MM::E
>
> ###################
> # test2.rb ???
> ###################
> --
> Posted via
http://www.ruby-...
.
Well, it's simple, if you say MM::C inside an M::MM's module_eval,
then it means M::MM::MM::C, and this is undefined. When you say Temp
\dir from inside C:\Temp, then it means C:\Temp\Temp\dir.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
I don't know why!!
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password