From: Caius Durling Date: 2010-12-29T08:39:37+09:00 Subject: Re: how do i run the function? On 28 Dec 2010, at 23:37, Rick Tan wrote: > If i want to run a function whose name is contained in a string, how do > I do that in Ruby? or is this not feasible? > > For example > > def a > puts "a" > end > > def b > puts "b" > end > > mymethod="a" > > In the above code snippet, i like to run the function a by using the > string mymethod. What trick if any can i use in ruby to make this > happen? Object#send. http://ruby-doc.org/core/classes/Object.html#M000332 (It'll take a string as well as a symbol.) C --- Caius Durling caius@caius.name +44 (0) 7960 268 100 http://caius.name/