Last active
May 25, 2016 20:56
-
-
Save practicingruby/a53fb8d14fce5f11c4eadd565c8c1b8a 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
class BrokenNumber | |
def initialize(num) | |
@num = num | |
end | |
def method_missing(m, *a, &b) | |
@num.send(m, *a, &b) | |
end | |
def coerce(other) | |
[self, self] | |
end | |
end |
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
>> require "./broken" | |
=> true | |
>> x = BrokenNumber.new(2) | |
=> #<BrokenNumber:0x007f832b9a9880 @num=2> | |
>> 2 + x | |
SystemStackError: stack level too deep | |
... | |
>> 2 + x | |
Segmentation fault: 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment