Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

ARGF#to_a

ARGF.to_a(sep = $/, chomp: false) → array
ARGF.to_a(limit, chomp: false) → array
ARGF.to_a(sep, limit, chomp: false) → array

Alias of #readlines

Reads each file in ARGF in its entirety, returning an Array containing lines from the files. Lines are assumed to be separated by sep.

Example
lines = ARGF.readlines
lines[0]                #=> "This is line one\n"

See IO.readlines for a full description of all options.

See also #readlines #tell #to_i #skip also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0