From: Brian Marick Date: 2001-10-07T09:20:10+09:00 Subject: [ruby-talk:22180] Redefining class that does not inherit with class that does Suppose that you run this code: class Sub def foo "SUB foo!" end end class Super def foo "SUPER foo!" end end # note: redefining Sub class Sub < Super def bar "bar!" end end You get a "warning: already initialized constant Sub", which seems fine. Question: when you do "Sub.new.foo", which foo do you get? I expected Super's - that the new version of Sub would wipe out the old. I was surprised that you got neither. foo is not a method Sub responds to. (bar is.) I'm not sure my expected behavior is correct. The second "class Sub" might instead add a method "bar" to the exiting "foo" and link Super into the inheritance chain of Sub. But eliminating "foo" seems odd. Ruby 1.6.3 Is there a way to destroy the old definition of Sub before the second "class Sub"? I'm writing text that explains inheritance, and it's awkward to say "if you're following along with IRB, be sure to exit your session now." -- Brian Marick, marick@testing.com www.testing.com - Software testing services and resources www.testingcraft.com - Where software testers exchange techniques www.visibleworkings.com - Adequate understanding of system internals