有沒有辦法做到這一點?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