I have a string that can be ‘+’, ‘-‘, ‘*’ or ‘/’, and two numbers. I need to apply the operation denoted by the string to the numbers. I tried:
op = '+'
(&op.to_sym).call 1, 2
but it won’t parse it. please help.
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.
Ruby is not a Polish notation language.