Skip to content

Instantly share code, notes, and snippets.

@stokarenko
Created June 18, 2018 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokarenko/3122ff650657ab6061a7c592a4cd42f7 to your computer and use it in GitHub Desktop.
Save stokarenko/3122ff650657ab6061a7c592a4cd42f7 to your computer and use it in GitHub Desktop.
module A
def func
p 'A'
super
end
end
class B
def func
p 'B'
super
end
end
class C < B
def func
p 'C'
super
end
end
B.include A
p C.ancestors # [C, B, A, Object, Kernel, BasicObject]
C.new.func # "C", "B", "A", "no superclass method `func'"
module A
def func
p 'A'
super
end
end
module B
def func
p 'B'
super
end
end
class C
include B
def func
p 'C'
super
end
end
B.include A
p B.ancestors # [B, A]
# NOTE: A is missing!
p C.ancestors # [C, B, Object, Kernel, BasicObject]
C.new.func # "C", "B", "no superclass method `func'"
module A
def func
p 'A'
super
end
end
module B
include A
def func
p 'B'
super
end
end
class C
include B
def func
p 'C'
super
end
end
p B.ancestors # [B, A]
p C.ancestors # [C, B, A, Object, Kernel, BasicObject]
C.new.func # "C", "B", "A", "no superclass method `func'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment