@@ -9693,11 +9693,53 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
9693
9693
9694
9694
/*
9695
9695
* call-seq:
9696
- * lines(Line_sep = $/, chomp: false) -> array_of_strings
9697
- *
9698
- * Forms substrings ("lines") of +self+ according to the given arguments
9699
- * (see String#each_line for details); returns the lines in an array.
9700
- *
9696
+ * lines(record_separator = $/, chomp: false) -> array_of_strings
9697
+ *
9698
+ * Returns substrings ("lines") of +self+
9699
+ * according to the given arguments:
9700
+ *
9701
+ * s = <<~EOT
9702
+ * This is the first line.
9703
+ * This is line two.
9704
+ *
9705
+ * This is line four.
9706
+ * This is line five.
9707
+ * EOT
9708
+ *
9709
+ * With the default argument values:
9710
+ *
9711
+ * $/ # => "\n"
9712
+ * s.lines
9713
+ * # =>
9714
+ * ["This is the first line.\n",
9715
+ * "This is line two.\n",
9716
+ * "\n",
9717
+ * "This is line four.\n",
9718
+ * "This is line five.\n"]
9719
+ *
9720
+ * With a different +record_separator+:
9721
+ *
9722
+ * record_separator = ' is '
9723
+ * s.lines(record_separator)
9724
+ * # =>
9725
+ * ["This is ",
9726
+ * "the first line.\nThis is ",
9727
+ * "line two.\n\nThis is ",
9728
+ * "line four.\nThis is ",
9729
+ * "line five.\n"]
9730
+ *
9731
+ * With keyword argument +chomp+ as +true+,
9732
+ * removes the trailing newline from each line:
9733
+ *
9734
+ * s.lines(chomp: true)
9735
+ * # =>
9736
+ * ["This is the first line.",
9737
+ * "This is line two.",
9738
+ * "",
9739
+ * "This is line four.",
9740
+ * "This is line five."]
9741
+ *
9742
+ * Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
9701
9743
*/
9702
9744
9703
9745
static VALUE
0 commit comments