Skip to content

Commit e47dec0

Browse files
committed
[DOC] Add doc for keyword arg chomp
1 parent 3dc4ad2 commit e47dec0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ext/stringio/stringio.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,26 @@ strio_readline(int argc, VALUE *argv, VALUE self)
15761576
* "First line\nSecond line\n\nFourth line\nFifth line\n"
15771577
* ```
15781578
*
1579+
* **Keyword Argument `chomp`**
1580+
*
1581+
* With keyword argument `chomp` given as `true` (the default is `false`),
1582+
* removes trailing newline (if any) from each line:
1583+
*
1584+
* ```
1585+
* strio = StringIO.new(TEXT)
1586+
* strio.each_line(chomp: true) {|line| p line }
1587+
* ```
1588+
*
1589+
* Output:
1590+
*
1591+
* ```
1592+
* "First line"
1593+
* "Second line"
1594+
* ""
1595+
* "Fourth line"
1596+
* "Fifth line"
1597+
* ```
1598+
*
15791599
* With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
15801600
*
15811601
* Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.

0 commit comments

Comments
 (0)