Skip to content

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

instance method

String#lines

(?::string? separator, ?chomp: ::boolish) -> ::Array[::String]
(?::string? separator, ?chomp: ::boolish) { (::String line) -> void } -> self
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 #intern #lstrip also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0