Is there something like this in ruby?
send(+, 1, 2)
I want to make this piece of code seem less redundant
if op == \"+\"
As an other option, if your operator and operands happen to be in string format, say from a gets method, you can also use eval:
gets
eval
For example:
a = '1'; b = '2'; o = '+'
eval a+o+b
becomes
eval '1+2'
which returns 3
3