ruby-changes:46887
From: stomar <ko1@a...>
Date: Sat, 3 Jun 2017 06:29:47 +0900 (JST)
Subject: [ruby-changes:46887] stomar:r59002 (trunk): string.c: docs for String#split
stomar 2017-06-03 06:29:27 +0900 (Sat, 03 Jun 2017) New Revision: 59002 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59002 Log: string.c: docs for String#split * string.c: [DOC] clarify docs for String#split when called with limit and capture groups. Reported by Cichol Tsai. [ruby-core:81505] [Bug #13621] Modified files: trunk/string.c Index: string.c =================================================================== --- string.c (revision 59001) +++ string.c (revision 59002) @@ -7285,7 +7285,7 @@ static const char isspacetable[256] = { https://github.com/ruby/ruby/blob/trunk/string.c#L7285 /* * call-seq: - * str.split(pattern=nil, [limit]) -> anArray + * str.split(pattern=nil, [limit]) -> an_array * * Divides <i>str</i> into substrings based on a delimiter, returning an array * of these substrings. @@ -7305,9 +7305,11 @@ static const char isspacetable[256] = { https://github.com/ruby/ruby/blob/trunk/string.c#L7305 * split on whitespace as if ' ' were specified. * * If the <i>limit</i> parameter is omitted, trailing null fields are - * suppressed. If <i>limit</i> is a positive number, at most that number of - * fields will be returned (if <i>limit</i> is <code>1</code>, the entire - * string is returned as the only entry in an array). If negative, there is no + * suppressed. If <i>limit</i> is a positive number, at most that number + * of split substrings will be returned (captured groups will be returned + * as well, but are not counted towards the limit). + * If <i>limit</i> is <code>1</code>, the entire + * string is returned as the only entry in an array. If negative, there is no * limit to the number of fields returned, and trailing null fields are not * suppressed. * @@ -7327,6 +7329,8 @@ static const char isspacetable[256] = { https://github.com/ruby/ruby/blob/trunk/string.c#L7329 * "1,2,,3,4,,".split(',', 4) #=> ["1", "2", "", "3,4,,"] * "1,2,,3,4,,".split(',', -4) #=> ["1", "2", "", "3", "4", "", ""] * + * "1:2:3".split(/(:)()()/, 2) #=> ["1", ":", "", "", "2:3"] + * * "".split(',', -1) #=> [] */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/