Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

ARGF#to_a

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

Alias of #readlines

Reads ARGF‘s current file in its entirety, returning an Array of its lines, one line per element. Lines are assumed to be separated by sep.

Example
lines = ARGF.readlines
lines[0]                #=> "This is line one\n"
See also #readlines #tell #to_i #skip also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1