问题:
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