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
string.c
View on GitHub ↗
static VALUE
rb_str_lines(int argc, VALUE *argv, VALUE str)
{
VALUE ary = WANTARRAY("lines", 0);
return rb_str_enumerate_lines(argc, argv, str, ary);
}
Forms substrings (“lines”) of self according to the given arguments (see String#each_line for details); returns the lines in an array.