在 ruby 中调用超类中的另一个方法 [英] calling another method in super class in ruby
本文介绍了在 ruby 中调用超类中的另一个方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
class B 一种别名 :super_a :a定义一个乙()结尾定义bsuper_a()结尾结尾
class A def a puts 'in #a' end end class B < A def a b() end def b # here i want to call A#a. end end
解决方案
class B < A
alias :super_a :a
def a
b()
end
def b
super_a()
end
end
这篇关于在 ruby 中调用超类中的另一个方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文