зеркало из https://github.com/github/ruby.git
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@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
eb02dd3c05
Коммит
7506fde3e9
8
string.c
8
string.c
|
@ -7641,8 +7641,8 @@ split_string(VALUE result, VALUE str, long beg, long len, long empty_count)
|
|||
*
|
||||
* 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, long beg, long len, long empty_count)
|
|||
* 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"]
|
||||
|
|
Загрузка…
Ссылка в новой задаче