What version of Ruby does this book use?
When I write the following code.
https://gist.github.com/anonymous/e3f55332903944509c1a4820b71d686bclass Number
def initialize(n)
@value = n
end
def to_s
@value.to_s
end
def inspect
"«#{self}»"
end
end
class Add
def initialize (left, right)
@left = left
@right = right
end
def to_s
"#{@left} + #{@right}"
end
def inspect
"«#{self}»"
end
end
class Multiply
def initialize (left, right)
@left = left
@right = right
end
def to_s
"#{@left} * #{@right}"
end
def inspect
"«#{self}»"
end
end
puts Add.new(
Multiply.new(Number.new(1), Number.new(2)),
Multiply.new(Number.new(3), Number.new(4))
)
puts Number.new(5)
I receive these errors.
./uc0.ruby:34:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from ./uc0.ruby:34:in `new'
from ./uc0.ruby:34:in `<main>'