How do i run the function?

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?

Thanks.

On 28 Dec 2010, at 23:37, Rick T. wrote:

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. class Object - RDoc Documentation (It’ll
take a string as well as a symbol.)

C

Caius D.
[email protected]
+44 (0) 7960 268 100
http://caius.name/