Dear all,
I’m trying to duplicate the RPN caculator code found Here. When I run my code I get an Error: undefined method `evaluate’ for main:Object (NoMethodError)
Any suggestions? It does not seem that the author would put up faulty code on her website.
class RPNCalculator
def evaluate(expression)
expression = expression.split
operands = []
evaluation = []
expression.each do |x|
case x
when /\d/
evaluation.push(x.to_f)
when "-", "/", "*", "+", "**"
operands = evaluation.pop(2)
evaluation.push(operands[0].send(x, operands[1]))
end
end
puts evaluation
end
end
input = "112++"
evaluate(input)
Thanks,
Bill