What are all the common ways to read a file in Ruby?
For instance, here is one method:
fileObj = File.new($fileName, "r")
while (line = fileObj.gets)
puts(line)
end
fileObj.close
I know Ruby is extremely flexible. What are the benefits/drawbacks of each approach?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…