From: Robert Dober Date: 2006-07-14T07:38:40+09:00 Subject: Re: challenge ------=_Part_15573_3363771.1152830317727 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7/14/06, ara.t.howard@noaa.gov wrote: > > 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 =3D 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 =3D 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. It does not, open is defined in IO, and becomes visible again :) regards. > > > -a > -- > suffering increases your inner strength. also, the wishing for suffering > makes the suffering disappear. > - h.h. the 14th dali lama > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_15573_3363771.1152830317727--