Ruby Quick Reference

Quick reference for efficient coding

View the Project on GitHub YumaYX/RubyQuickReference

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.5