比如如下代码:
class Man
def dd
puts 'Man-dd'
end
end
class Boy < Man
def dd
puts '..boy..'
super.dd
puts '..boy..'
end
end
boy = Boy.new
boy.dd
会输出:
..boy..
Man-dd
d.rb:10:in `dd': undefined method `dd' for nil:NilClass (NoMethodError)
from d.rb:17:in `<main>'
也就是说,"super.dd"这句出了问题。