Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.