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

ruby-changes:50710

From: nobu <ko1@a...>
Date: Thu, 22 Mar 2018 01:02:31 +0900 (JST)
Subject: [ruby-changes:50710] nobu:r62881 (trunk): Improve documentation for 'text '.split

nobu	2018-03-22 01:02:26 +0900 (Thu, 22 Mar 2018)

  New Revision: 62881

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

  Log:
    Improve documentation for 'text '.split
    
    The documentation didn't mention trailing spaces and the
    example only demonstrated the case with leading spaces.
    [Fix GH-1845]
    
    From: Rodrigo Rosenfeld Rosas <rr.rosas@g...>

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 62880)
+++ string.c	(revision 62881)
@@ -7641,8 +7641,8 @@ split_string(VALUE result, VALUE str, lo https://github.com/ruby/ruby/blob/trunk/string.c#L7641
  *
  *  If <i>pattern</i> is a <code>String</code>, then its contents are used as
  *  the delimiter when splitting <i>str</i>. If <i>pattern</i> is a single
- *  space, <i>str</i> is split on whitespace, with leading whitespace and runs
- *  of contiguous whitespace characters ignored.
+ *  space, <i>str</i> is split on whitespace, with leading and trailing
+ *  whitespace and runs of contiguous whitespace characters ignored.
  *
  *  If <i>pattern</i> is a <code>Regexp</code>, <i>str</i> is divided where the
  *  pattern matches. Whenever the pattern matches a zero-length string,
@@ -7665,8 +7665,8 @@ split_string(VALUE result, VALUE str, lo https://github.com/ruby/ruby/blob/trunk/string.c#L7665
  *  When the input +str+ is empty an empty Array is returned as the string is
  *  considered to have no fields to split.
  *
- *     " now's  the time".split        #=> ["now's", "the", "time"]
- *     " now's  the time".split(' ')   #=> ["now's", "the", "time"]
+ *     " now's  the time ".split       #=> ["now's", "the", "time"]
+ *     " now's  the time ".split(' ')  #=> ["now's", "the", "time"]
  *     " now's  the time".split(/ /)   #=> ["", "now's", "", "the", "time"]
  *     "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"]
  *     "hello".split(//)               #=> ["h", "e", "l", "l", "o"]

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

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