Last active
November 18, 2020 10:40
-
-
Save jeffkreeftmeijer/c1c6f31750bfe1ab1012b6601c9ea38e 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 Foo | |
def foo | |
puts "ok!" | |
end | |
end | |
Foo.prepend(Module.new do | |
def foo | |
puts "prepend!" | |
super | |
end | |
end) | |
Foo.class_eval { | |
alias_method :old_foo, :foo | |
def foo | |
puts "class_eval!" | |
old_foo() | |
end | |
} | |
Foo.new.foo | |
# prepend! | |
# class_eval! | |
# prepend! | |
# class_eval! | |
# prepend! | |
# class_eval! | |
# ... | |
# prepend! | |
# class_eval! | |
# prepend! | |
# class_eval! | |
# prepend! | |
# class_eval! | |
# prepend! | |
# class_eval! | |
# Traceback (most recent call last): | |
# 11913: from system_stack_error.rb:24:in `<main>' | |
# 11912: from system_stack_error.rb:10:in `foo' | |
# 11911: from system_stack_error.rb:20:in `foo' | |
# 11910: from system_stack_error.rb:10:in `foo' | |
# 11909: from system_stack_error.rb:20:in `foo' | |
# 11908: from system_stack_error.rb:10:in `foo' | |
# 11907: from system_stack_error.rb:20:in `foo' | |
# 11906: from system_stack_error.rb:10:in `foo' | |
# ... 11901 levels... | |
# 4: from system_stack_error.rb:10:in `foo' | |
# 3: from system_stack_error.rb:20:in `foo' | |
# 2: from system_stack_error.rb:9:in `foo' | |
# 1: from system_stack_error.rb:9:in `puts' | |
# system_stack_error.rb:9:in `puts': system_stack_error level too deep (SystemStackError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment