Friday, September 24, 2010

ruby send method

Hi all

I am started using the method named "send".

We can use this to call the method using object.

class User

def say_hello
"Hello"
end

end

u = User.new
puts u.send(:say_hello)

Here the class "User" is having the method called say_hello. We can create an object for the user class and call the method using the method "send"

Cheers,
vadivelan

No comments:

Post a Comment