From: Timothy Hunter Date: 2007-03-14T10:58:59+09:00 Subject: Re: calling a method using a variable name?? ajtwatching wrote: > Hey folks, > > Like many posts have no doubt started.. I'm giving this ruby business > a crack!! ;) > > Now this might be a really bad approach.. but I'll throw it out there. > > Here's my simple class. > > class Myclass > def initialize > end > > def hello > puts "hello" > end > > def bye > puts "bye" > end > end > > As expected, works a treat. > > friendly = Myclass.new > friendly.hello > friendly.bye > > Now, given I now what methods are available, is there a way to do > something similar to this... > > methods = ['hello', 'bye'] > methods.each { |m| friendly.m } > > Regards, > > ajt. > > > Look up the __send__ method: obj.__send__("methodname", arg1, arg2)