作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我有一个调用基础实现的方法:
class B
def m x, y
x + y
end
end
class C < B
def m x, y
super * 10
end
end
因为我从不在我的派生方法中引用参数,有没有办法避免在 C.m
中使用参数名称?
最佳答案
我认为这是您最接近的:
class B
def m x, y
x + y
end
end
class C < B
def m *args
super * 10
end
end
=> C.new.m 10, 10 # 200
=> C.new.m 1, 2, 3 # ArgumentError
关于ruby - super 的论据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14327285/
我是一名优秀的程序员,十分优秀!