Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2016 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/e3f55332903944509c1a4820b71d686b to your computer and use it in GitHub Desktop.
Save anonymous/e3f55332903944509c1a4820b71d686b to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby -w
puts "Understanding Computation";
class Number
def to_s
value.to_s
end
def inspect
#{self}»"
end
end
class Add
def to_s
"#{left} + #{right}"
end
def inspect
#{self}»"
end
end
class Multiply
def to_s
"#{left} * #{right}"
end
def inspect
#{self}»"
end
end
Add.new(
Multiply.new(Number.new(1), Number.new(2)),
Multiply.new(Number.new(3), Number.new(4))
)
Number.new(5)
How do I fix the following error?
./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>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment