In Ruby, you can use the “send” method to call a function.
Example:
class MyClass
def my_function
puts “in my function”
end
end
c = MyClass.new
function_name = “my_function”
c.send(function_name)
HTH,
Keith
On 4/18/06 3:00 PM, "Rodrigo Julian Martin" <[EMAIL PROTECTED]> wrote:
Hello!
I have another code question…
Can I call an object method by using a variable?
I’ve tried something like this:
propertie=”className”
a = Item(80).’#{propertie}’
And obviously doesn’t work…
I’ve also tried:
a = Item(80).{propertie}
but this is a call to a hash…
Any help would be really appreciated…
Thanks in Advance!
Rodrigo Julian Martin
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
