Skip to the content.

to_array.rb(file)

It reads the file, creates an array of lines, and then removes the newline character from each line in the array.

Execution:

File.readlines('file.txt').map(&:chomp)
#=> ["line1", "line2", "line3"]

Executed with Ruby 3.3.6