0
这是错误。没有这样的文件或目录
Atrosity [ Eric-Raios-MacBook ][ ~/dev/rubyscripts ]$ ruby script.rb
script.rb:7:in `read': No such file or directory - sent (Errno::ENOENT)
from script.rb:7:in `lSent'
from script.rb:16:in `<main>'
我的方法,导致该错误是:
def lSent
$sent = Set.new(File.read("sent").split(";"))
end
lSent
如果我删除,我的脚本运行,但确实不是我想要做的输出。
您可以检查文件是否存在使用'File.exist?(文件名)' –