gpt4 book ai didi

ruby - 如果满足给定条件,则结束 ruby​​ 程序

转载 作者:数据小太阳 更新时间:2023-10-29 07:11:46 25 4
gpt4 key购买 nike

基本上,我只是试图在满足特定条件时停止程序运行其余行。

unless raw_information.first
puts "No results were returned for that query"
break
end

然而,在程序运行之前我得到了这个错误:

Invalid break compile error (SyntaxError)

执行此操作的正确方法是什么?

最佳答案

abort("No results were returned for that query") unless condition

unless condition
abort("No results were returned for that query")
end

关于ruby - 如果满足给定条件,则结束 ruby​​ 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6804237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com