我如何從佣金任務中提前返回? - How do I return early from a rake task?

問題:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章