In Obj-C, the method to invoke can be decided at runtime using selector mechanism.
Is there anything similar in Ruby so that I can convert a method string into a method symbol at runtime and invoke it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want the
sendmethod:obj.send(method_name), wheremethod_namecan be either a string or a symbol, will invoke the method with the given name onobj.Any arguments you want to pass to the method, can be given as additional arguments to
send, i.e.obj.send(method_name, argument1, argument2).