2016-08-11 3 views
0

ルビー2.0ルビー - 予期しない戻り(LocalJumpError)

はなぜ以下のコードは、予期しない戻り(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) 

Error: unexpected return (LocalJumpError)

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

'return'を削除してください –

答えて

3

あなたはこの方法ではありません。そこからはreturnはできません。早めに終了したい場合は、exitを使用してください。

関連する問題