Ruby 3 · Errors and files
Write a file
Write text, with the file closed automatically at the end of the block.
File.open("out.txt", "w") { |f| f.puts "hello" }
Ruby 3 · Errors and files
Write text, with the file closed automatically at the end of the block.
File.open("out.txt", "w") { |f| f.puts "hello" }
Was this page helpful?