有没有办法做到这一点?Ruby - 继承方法Order
class Parent
def stuff
#error checking that needs to go first
end
end
class Young < Parent
def stuff
super
p 'doing new stuff here'
end
end
此代码看起来通过super调用父方法,然后它永远不会返回到“做新东西”部分。
它确实返回到“在这里做新东西”部分。也许实际的代码退出或引发异常。 – ndn
哦,好吧。你想补充说,作为我能接受的答案吗?我应该删除我的帖子吗? – appleLover
如果需要,您可以将其删除,或者让社区将其作为*不再可复制*进行关闭。 – ndn