From: Adam Bozanich Date: 2007-06-25T07:48:02+09:00 Subject: Re: variables to call methods in ruby... ------=_Part_148872_31969476.1182725283445 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 6/24/07, Harnish wrote: > > Hi, > > This is Harnish. I was just wondering if I could call methods using > variables? > > As for example: > > ----------------- > testfunc = "func" > > class Test > def self.func > puts "hello there...!" > end > end > > Test. > ----------------- > > Essentially I want to call Test.func; but "func" lies in the variable > testfunc; is it possible for me to invoke Test.func using variable > testfunc? If yes, how? Any ideas, greatly appreciated. You can use send: testfunc = "func" class Test def self.func puts "hello there...!" end end Test.send testfunc ------=_Part_148872_31969476.1182725283445--