From: Trans Date: 2006-07-23T02:05:11+09:00 Subject: Re: when I say method_defined? I mean it! Erik Veenstra wrote: > > def wrap_method( sym, &blk ) > > raise ArgumentError, "method does not exist -- #{sym}" unless method_defined?( sym ) > > old = instance_method(sym) > > define_method(sym) { |*args| blk.call(old.bind(self), *args) } > > end > > Replace "unless method_defined?( sym )" with "unless > (method(sym) rescue nil)". Tha won't work b/c it would be looking at the module or classes methods, not the instance methods. > But you don't need this check. instance_method(sym), on the > next line, already performs this check for you. Oh right, thanks, I'll change. Nonetheless if I wanted to do something else with the check, the point of my post remains. It silly to have to check public_methods || private_methods || protected_methods When #instance_methods should just correspond to the behavior to #instance_method. I mean, isn;t reasonable to think those two methods would have the same lookup behavior? T.