I don't know why!

– 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 ???

###################

On Aug 8, 3:57 am, Kyung won Cheon [email protected] wrote:

class E < MM::C; puts self; end
end

=> uninitialized constant M::MM::MM (NameError)

###################

Posted viahttp://www.ruby-forum.com/.

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.

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