-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex44d.rb
More file actions
42 lines (33 loc) · 726 Bytes
/
ex44d.rb
File metadata and controls
42 lines (33 loc) · 726 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
class Parent
def override()
puts "PARENT override()"
end
def implicit()
puts "PARENT implicit()"
end
def altered()
puts "PARENT altered()"
end
end
class Child < Parent
def override()
puts "CHILD override"
end
def altered()
puts "CHILD BEFORE PARENT, altered()"
super()
puts "CHILD AFTER PARENT, altered()"
end
end
dad = Parent.new()
son = Child.new()
dad.implicit()
son.implicit()
dad.override()
son.override()
dad.altered()
son.altered()
# Most commonly, we'll use super() with initialize.
# When we define a new subclass, we'll potentially want to do some
# things in the chld, then finish the initializatonin the parent.
# I need to investigate this more.