gpt4 book ai didi

Ruby - 意外返回(LocalJumpError)

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

ruby 2.0

为什么下面的代码会给出意外的返回(LocalJumpError)?

# some code here
puts "Scanning for xml files .."
zip_files = Dir.entries(directory).select { |f| File.extname(f) == '.zip' }
if(zip_files.count == 0)
puts "No files found, exiting..."
return
end
# more code here ( if files found)

错误:意外返回(LocalJumpError)

No files found, exiting...
[Finished in 0.9s with exit code 1]

最佳答案

您不在方法中。你不能 return从那里。如果您想提前退出,请使用 exit .

关于Ruby - 意外返回(LocalJumpError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38885985/

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