問題:
I have a rake task where I do some checks at the beginning, if one of the checks fails I would like to return early from the rake task, I don't want to execute any of the remaining code.我有一個 rake 任務,我在開始時進行了一些檢查,如果其中一個檢查失敗,我想從 rake 任務中儘早返回,我不想執行任何剩餘的代碼。
I thought the solution would be to place a return where I wanted to return from the code but I get the following error我認爲解決方案是在我想從代碼返回的地方放置一個返回,但我收到以下錯誤
unexpected return
解決方案:
參考一: https://en.stackoom.com/question/9icV參考二: https://stackoom.com/question/9icV