Created
November 9, 2016 19:25
-
-
Save anonymous/e3f55332903944509c1a4820b71d686b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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