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#gets

ARGF.gets(sep=$/ [, getline_args]) → string or nil
ARGF.gets(limit [, getline_args]) → string or nil
ARGF.gets(sep, limit [, getline_args]) → string or nil

Returns the next line from the current file in ARGF.

By default lines are assumed to be separated by $/; to use a different character as a separator, supply it as a String for the sep argument.

The optional limit argument specifies how many characters of each line to return. By default all characters are returned.

See IO.readlines for details about getline_args.

See also #getc #inplace_mode #getbyte #inplace_mode= also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1