Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Last active May 25, 2016 20:56
Show Gist options
  • Save practicingruby/a53fb8d14fce5f11c4eadd565c8c1b8a to your computer and use it in GitHub Desktop.
Save practicingruby/a53fb8d14fce5f11c4eadd565c8c1b8a to your computer and use it in GitHub Desktop.
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
>> 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