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 ???
###################
--
Posted via http://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.

···

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 &lt; MM::C
end

class E &lt; MM::C; puts self; end

end
end

# => M::MM::E

-- test2.rb --

module M
module MM
class C
end

class D &lt; MM::C
end

\#class E &lt; 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 &lt; MM::C
end

\#class E &lt; MM::C; puts self; end

end
end

M::MM.module_eval("class E < C; puts self; end")

# => M::MM::E

###################
# test2.rb ???
###################
--
Posted viahttp://www.ruby-forum.com/.