[前][次][番号順一覧][スレッド一覧]

ruby-changes:48509

From: stomar <ko1@a...>
Date: Fri, 3 Nov 2017 05:38:09 +0900 (JST)
Subject: [ruby-changes:48509] stomar:r60624 (trunk): io.c: improve docs for the chomp option

stomar	2017-11-03 05:38:04 +0900 (Fri, 03 Nov 2017)

  New Revision: 60624

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60624

  Log:
    io.c: improve docs for the chomp option
    
    * io.c: [DOC] improve the description for the chomp option and
      add examples to IO.readlines and IO#readlines; other small fixes.

  Modified files:
    trunk/io.c
Index: io.c
===================================================================
--- io.c	(revision 60623)
+++ io.c	(revision 60624)
@@ -3620,10 +3620,10 @@ static VALUE io_readlines(const struct g https://github.com/ruby/ruby/blob/trunk/io.c#L3620
  *     ios.readlines(sep, limit [, getline_args]) -> array
  *
  *  Reads all of the lines in <em>ios</em>, and returns them in
- *  <i>anArray</i>. Lines are separated by the optional <i>sep</i>. If
+ *  an array. Lines are separated by the optional <i>sep</i>. If
  *  <i>sep</i> is +nil+, the rest of the stream is returned
  *  as a single record.
- *  If the first argument is an integer, or
+ *  If the first argument is an integer, or an
  *  optional second argument is given, the returning string would not be
  *  longer than the given value in bytes. The stream must be opened for
  *  reading or an <code>IOError</code> will be raised.
@@ -3631,6 +3631,9 @@ static VALUE io_readlines(const struct g https://github.com/ruby/ruby/blob/trunk/io.c#L3631
  *     f = File.new("testfile")
  *     f.readlines[0]   #=> "This is line one\n"
  *
+ *     f = File.new("testfile", chomp: true)
+ *     f.readlines[0]   #=> "This is line one"
+ *
  *  See IO.readlines for details about getline_args.
  */
 
@@ -10268,6 +10271,9 @@ io_s_readlines(struct getline_arg *arg) https://github.com/ruby/ruby/blob/trunk/io.c#L10271
  *     a = IO.readlines("testfile")
  *     a[0]   #=> "This is line one\n"
  *
+ *     b = IO.readlines("testfile", chomp: true)
+ *     b[0]   #=> "This is line one"
+ *
  *  If the last argument is a hash, it's the keyword argument to open.
  *
  *  === Options for getline
@@ -10275,11 +10281,11 @@ io_s_readlines(struct getline_arg *arg) https://github.com/ruby/ruby/blob/trunk/io.c#L10281
  *  The options hash accepts the following keys:
  *
  *  :chomp::
- *    Specifies the boolean. It will remove \n, \r, and \r\n
- *    from the end of each lines if it's true
- *
- *  And see also IO.read for details about open_args.
+ *    When the optional +chomp+ keyword argument has a true value,
+ *    <code>\n</code>, <code>\r</code>, and <code>\r\n</code>
+ *    will be removed from the end of each line.
  *
+ *  See also IO.read for details about open_args.
  */
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]