N
Neutek
I'm trying to figure out how to pass methods such as:
+, -, **, ^
to a method and evaluate.
For example,
def test(a, b, to_do)
return a.send(to_do(b))
end
puts test(1, 2, "+") #should return 3
puts test(3, 3, "^") #should return 0
puts test(3, 3, "**") #should return 27
any help would be appreciated.
+, -, **, ^
to a method and evaluate.
For example,
def test(a, b, to_do)
return a.send(to_do(b))
end
puts test(1, 2, "+") #should return 3
puts test(3, 3, "^") #should return 0
puts test(3, 3, "**") #should return 27
any help would be appreciated.