Created
October 13, 2021 11:25
-
-
Save zhulik/1df6b56d02b2e11f10a28e851da50cd6 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 A | |
def foo | |
p("A::Foo") | |
end | |
alias foo1 foo | |
end | |
class B < A | |
def foo | |
p("B::Foo") | |
end | |
end | |
B.new.foo1 # "A::Foo is printed" | |
class C | |
def foo | |
p("C::Foo") | |
end | |
alias_method :foo1, :foo | |
end | |
class D < C | |
def foo | |
p("D::Foo") | |
end | |
end | |
D.new.foo1 # "C::Foo is printed" | |
require 'forwardable' | |
class E | |
extend Forwardable | |
def foo | |
p("C::Foo") | |
end | |
def_delegator :self, :foo, :foo1 | |
end | |
class F < E | |
def foo | |
p("F::Foo") | |
end | |
end | |
F.new.foo1 # "F::Foo is printed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment