【发布时间】:2015-12-27 06:33:05
【问题描述】:
有没有办法做到这一点?
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调用父方法,然后它永远不会返回到“做新东西”部分。
【问题讨论】:
-
它确实返回到
'doing new stuff here'部分。可能实际代码退出或引发异常。 -
哦,好吧。你想添加它作为我可以接受的答案吗?我应该删除我的帖子吗?
-
您可以根据需要将其删除,也可以让社区将其关闭为不再可复制。
-
是的,删除它。现在它没有任何价值了。
标签: ruby inheritance methods super