在开始之前先复习一下其最简单的继承。
class A #定义父类
def a
p 'A a method'
end
end
class B < A#定义子类,让类B继承类A
def a
p 'B a method start'
super
p 'B a method end'
end
end
b = B.new
b.a
执行结果:
"B a method start" "A a method" "B a method end"