Last active
July 9, 2024 12:43
-
-
Save wyodeb/4190bb2823a63128330bef08d2c6adaf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class FakeNumber | |
def initialize(value) | |
@value = value | |
end | |
def +(other) | |
@value + other.to_i | |
end | |
def to_i | |
@value | |
end | |
def to_s | |
@value.to_s | |
end | |
end | |
num1 = FakeNumber.new(5) | |
num2 = FakeNumber.new(10) | |
puts num1 + num2 # Outputs: 15 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment