From: "David A. Black" Date: 2009-01-03T04:32:59+09:00 Subject: Re: What does 'Monkey Patching' exactly Mean in Ruby? Hi -- On Sat, 3 Jan 2009, Tom Link wrote: >> If you're really finding it necessary to create a whole class and a >> method_missing apparatus to make gsub! chainable > > This referred to the example of str += "foo". I was simply elaborating > on my alternative proposal. > >> Part of the point of the #extend >> technique is that it requires pin-pointing what you actually need > > You'd have to make sure you are the only user of that object then, > wouldn't you? You couldn't really make such objects publicly > accessible? Could be fun to debug code that returns such objects from > a method. Right; I'm advocating being quite conservative about changing core behaviors, and #extend is a relatively, but not absolutely, conservative way. I like #extend in general -- not just to avoid making global changes but also just because it's such a powerful way to design an object. It often feels tighter to me than creating a new class. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!