Can someone please tell me what the following snippet
obj.send("#{method_name}")
is and does?
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.
sendsends a message to an object instance and its ancestors in class hierarchy until some method reacts (because its name matches the first argument).Practically speaking, those lines are equivalent:
Note that
sendbypasses visibility checks, so that you can call private methods, too (useful for unit testing).If there is really no variable before send, that means that the global Object is used: