From: ara.t.howard@... Date: 2006-07-14T07:32:55+09:00 Subject: Re: challenge On Fri, 14 Jul 2006, Pit Capitain wrote: > ara.t.howard@noaa.gov schrieb: >> On Fri, 14 Jul 2006 Ara.T.Howard@noaa.gov wrote: >>> >>> OPEN = File.method 'open' >>> >>> class File >>> def self.open(*a) 42 end >>> end >>> end >>> >>> ## now restore File.open using OPEN - remember that open takes a block... >> >> correction. start here >> >> open_m = File.method 'open' >> >> class File >> def self.open(*a) 42 end >> end >> end >> >> using a const makes it too easy and will accomplish what i need to do. > > class << File; self; end.class_eval do > remove_method :open > end wow. learn something every day! ~ > cat a.rb class File def File.open(*a) 42 end end p File.open(__FILE__) class << File; self; end.class_eval do remove_method :open end p File.open(__FILE__) ~ > ruby a.rb 42 # i wasn't aware remove_method had this 'stacklike' quality. regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama