From: "David A. Black" Date: 2009-01-04T04:51:54+09:00 Subject: Re: What does 'Monkey Patching' exactly Mean in Ruby? Hi -- On Sun, 4 Jan 2009, Robert Dober wrote: > On Sat, Jan 3, 2009 at 2:54 AM, David A. Black wrote: > >> >> It doesn't allow it to run with 1.8, though, at least not safely. This >> kind of thing is pretty common in 1.8: >> >> instance_methods.each {|m| undef(m) unless m =~ /^__/ } > Very important point, I guess we can conclude two things from this > 1st in this case it was a pretty bad idea to use symbols, using > strings would have been better > but not overriding instance_methods but by providing a > instance_methods_as_strings method (this is somehow superfluous as we > will see in the second point) > 2nd we have to write a completely new class of Ruby programs for > 1.8/1.9 and an example will be code like this > instance_methods.each{ .... unless m.to_s =~ /^__/ } Except.... $ ruby19 -ve 'p :abc =~ /a/' ruby 1.9.1 (2008-12-30 patchlevel-0 revision 21203) [i386-darwin9.5.0] 0 Symbols are (somewhat too, for my taste) string-like in 1.9. (I know this is just an example, but it's interesting to note this side point I think.) 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!