Created
June 29, 2012 05:11
-
-
Save nakamura-akifumi/3015901 to your computer and use it in GitHub Desktop.
superのテスト
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
module M | |
def foo | |
puts "M#foo" | |
super | |
end | |
end | |
class Object | |
Const1 = "Object.Const1" | |
def foo | |
puts "Object#foo" | |
end | |
end | |
class C1 | |
def foo | |
puts "C1#foo" | |
super | |
end | |
private | |
def bar | |
puts "C1#bar" | |
end | |
end | |
class C2 < C1 | |
include M | |
def foo | |
puts "C2#foo" | |
super | |
end | |
def bar | |
super | |
end | |
end | |
puts "ancestors=" | |
p C2.ancestors | |
C2.new.foo | |
p "private" | |
C2.new.bar | |
C1.new.bar | |
class C1 | |
public :bar | |
end | |
C1.new.bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment