how to store a Ruby array into a file?

Viewed 17990

How to store a Ruby array into a file?

7 Answers

Example: write text_area to a file where text_area is an array of strings.

File.open('output.txt', 'w') { |f| text_area.each { |line| f << line } }

Don't forget to do error checking on file operations :)

Related