a file handle/object is assigned to f directly. : close a file « File Directory « Ruby






a file handle/object is assigned to f directly.


# You close the file handle manually with the close method at the end.

f = File.new("text.txt", "r")
puts f.gets
f.close

 








Related examples in the same category