From: KDr2 Date: 2007-03-14T11:15:15+09:00 Subject: Re: calling a method using a variable name?? "ajtwatching" writes: > 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 } methods.each{|m| friendly.send m} > > Regards, > > ajt. > > -- http://kdr2.net ------yours Killy Draw