method
lines
lines(*args)
public
Returns an array of lines in str split using the supplied record separator ($/ by default). This is a shorthand for str.each_line(separator, getline_args).to_a.
See IO.readlines for details about getline_args.
"hello\nworld\n".lines #=> ["hello\n", "world\n"] "hello world".lines(' ') #=> ["hello ", " ", "world"] "hello\nworld\n".lines(chomp: true) #=> ["hello", "world"]
If a block is given, which is a deprecated form, works the same as each_line.