From: Pit Capitain Date: 2006-08-15T02:13:56+09:00 Subject: Re: Calling non-existing methods works! (little magic??) Martin S. Weber schrieb: > I am kind of ... confused. Up till now I had the illusion you could only > call methods on an object which you could also find via methods or via > the included modules. Fine... Why does this output what it does then? > Where is this method defined? Some kind of method lookup cache? How to > force flushing it (besides redefining the methods of the receiver?) > (...) Martin, this seems to be a bug. As you guessed, there is a method lookup cache, and it isn't flushed correctly when removing a method. Here's a simpler code to show the bug... Define a module, include it in a class and call a method of the module: module M def m p "M#m" end end class C include M end C.new.m # => "M#m" Remove the method from the module: module M remove_method :m end The method lookup cache of class C isn't cleared (bug), so you can still call the old method: C.new.m # => "M#m" Here's one way to clear the method lookup cache for a given method: create an anonymous module and define a method with the same name: Module.new do def m end end C.new.m rescue p $! # => #> I will forward this to the ruby-core mailing list. Thanks for the bug report, Pit