面试题答案
一键面试begin
file_path = ARGV[0]
raise "No file path provided" if file_path.nil?
content = File.read(file_path)
word_count = content.split.size
puts "单词数量: #{word_count}"
rescue Errno::ENOENT
puts "文件不存在"
rescue StandardError => e
puts "发生错误: #{e.message}"
end