From: Robert Klemme Date: 2007-09-06T02:37:34+09:00 Subject: Re: Method switching 2007/9/5, Lee Jarvis : > Robert Klemme wrote: > > Since you are dispatching based on an instance variable, why don't you > > wrap send and colorsend in another method that does the dispatching > > and invoke this other method from your 50+ methods? > > how so? def wrap_send(m) if @color = 1 colorsend(m) else send(m) end end def some_method ... wrap_send("foo") ... end > > Btw, send is a bad name to choose because this is a standard method. > > Yeah i know.. it's not actually send, that was just an example > > > > I also wonder why you have 50+ methods that are somehow similar. > > Who said they were similar? It seemed so since all of them need that printing to be done. You might get better results when refactoring your code. > They all print different data to the console.. I just want to give the > user the choice, /SET COLOR=1 or something similar and the rest of the > data becomes colored.. > > Maybe i should not be printing data from every different method, if i > was only returning data then i suppose i could control the output type > in one method.. Maybe. I can't tell because I still have too little information. > Thanks for the help also.. ywc Kind regards robert