Creating and writing to a file

Hey guys,
What would be the best way to create and write to a file? Thanks.

Depends what you’re writing and to where. To create and write to a
simple text file is easy:

File.open(‘filename’,‘w’) { |f|
f.puts ‘text to write to file’
}

On Nov 16, 2:47 pm, Eamon F. [email protected]

François Montel wrote:

Depends what you’re writing and to where. To create and write to a
simple text file is easy:

File.open(‘filename’,‘w’) { |f|
f.puts ‘text to write to file’
}

On Nov 16, 2:47 pm, Eamon F. [email protected]

Cool, thanks. That’s all I need.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs