Simple ruby program not working

I’m trying to simply add 200 to index, but am getting the error:
initialize': undefined method+’ for #<NumNode:0x82537b4 @num=2>
(NoMethodError)”
Any thoughts on how I can fix this?

class StoreNode < UnaryNode
def initialize(subTree, index)
super(subTree)
@theIndex = index + 200
end

def evaluate()
i = @subTree.evaluate()
$calc.out.write(“M[”)
$calc.out.write(@theIndex)
$calc.out.write("]:= M[sp + 0]\n")
end
end

On Tue, Feb 4, 2014 at 5:13 PM, Conor Mr [email protected] wrote:

I’m trying to simply add 200 to index, but am getting the error:
initialize': undefined method+’ for #<NumNode:0x82537b4 @num=2>
(NoMethodError)”
Any thoughts on how I can fix this?

Define a “+” method on the “NumNode” class?

Thank you! Got it working.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs