Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

String#lines

lines(Line_sep = $/, chomp: false) → array_of_strings

Forms substrings (“lines”) of self according to the given arguments (see String#each_line for details); returns the lines in an array.

See also #length #ljust #kconv #lstrip also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0