From: Todd Benson Date: 2008-05-17T08:04:34+09:00 Subject: Re: Monkey Patching (definition)? On Fri, May 16, 2008 at 3:20 PM, ThoML wrote: >> There was a long discussion on the topic in this thread: >> > > And there even is a wikipedia article on MP: > http://en.wikipedia.org/wiki/Monkey_patching Interesting side note: class C def foo obj 'foo ' << obj.to_s end end c = C.new class C unless respond_to?('foo') def foo obj 'bar ' << obj.to_s end end end class Array unless respond_to?('==') def == obj 'arr == ' << obj.to_s end end end puts c.foo(42) # bar 42 -- the new method ran over the old one puts [] == 42 # false -- the new method was ignored The parser doesn't check the unless condition for 'normal' methods. (This is on 1.8.6) Todd