From: Ezra Zygmuntowicz Date: 2007-05-26T14:57:31+09:00 Subject: Re: Newbie question: variable method call On May 25, 2007, at 10:50 PM, Kal Starkis wrote: > Is there a way to use the value of a variable to call a method of that > name? > > For example, rather than use the following code to determine which > method of the 'pet' object to call: > > if action == "feed" > pet.feed > elsif action == "walk" > pet.walk > elsif action == "pat" > pet.pat > #etc... > end > > > I'd rather just do something like this: > > pet.action pet.send action Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)