-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex44.rb
More file actions
61 lines (53 loc) · 955 Bytes
/
Copy pathex44.rb
File metadata and controls
61 lines (53 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Grandpa
def hello()
puts "Hi, I'm your grandpa."
end
end
class Parent < Grandpa
def hello()
puts "Hi, I'm your parent."
puts "After called super()"
super()
end
def implicit()
puts "This is parent."
end
def override()
puts "PARENT override()"
end
def altered()
puts "PARENT altered()"
end
end
class Child < Parent
def hello()
puts "Hi, I'm a child."
puts "After called super()"
super()
end
def override()
puts "CHILD overide()"
end
def altered()
puts "CHILD, before PARENT altered()"
super()
puts "CHILD, after PARENT altered()"
end
end
grandpa = Grandpa.new()
parent = Parent.new()
child = Child.new()
puts "Here comes Grandpa!"
grandpa.hello()
puts '*' * 30
puts "Here comes Parent!"
parent.hello()
parent.implicit()
parent.override()
parent.altered()
puts '*' * 30
puts "Here you come."
child.hello()
child.implicit()
child.override()
child.altered()