Actions
Bug #11729
closedString#split(nil) incorrectly uses $;
Bug #11729: String#split(nil) incorrectly uses $;
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-11-21 trunk 52698) [x86_64-darwin14]
Description
Hi,
Is this intentional?
$; = "@" "a@b".split(nil) # => ["a", "b"] I expect ["a@b"] because I found the following sentence in the Japanese documentation.
1 バイトの空白文字 ' ' か nil 先頭と末尾の空白を除いたうえで、空白文字列で分割する。 http://docs.ruby-lang.org/ja/2.2.0/method/String/i/split.html
Updated by yui-knk (Kaneko Yuichiro) almost 10 years ago
Updated by yugui (Yuki Sonoda) almost 10 years ago
String#split started to accept nil as a separator in Ruby 1.5/1.6. And the bahavior has not been changed since Ruby 1.6.
Maybe this is a documentation bug of RuReMa.
Updated by yugui (Yuki Sonoda) almost 10 years ago
- Status changed from Open to Closed
Updated by yugui (Yuki Sonoda) almost 10 years ago
Updated by yui-knk (Kaneko Yuichiro) almost 10 years ago
I think it is better to fix the document of String#split
--- a/string.c +++ b/string.c @@ -6701,7 +6701,7 @@ static const char isspacetable[256] = { /* * call-seq: - * str.split(pattern=$;, [limit]) -> anArray + * str.split(pattern=nil, [limit]) -> anArray * * Divides <i>str</i> into substrings based on a delimiter, returning an array * of these substrings. @@ -6716,8 +6716,8 @@ static const char isspacetable[256] = { * <i>str</i> is split into individual characters. If <i>pattern</i> contains * groups, the respective matches will be returned in the array as well. * - * If <i>pattern</i> is omitted, the value of <code>$;</code> is used. If - * <code>$;</code> is <code>nil</code> (which is the default), <i>str</i> is + * If <i>pattern</i> is <code>nil</code>, the value of <code>$;</code> is used. + * If <code>$;</code> is <code>nil</code> (which is the default), <i>str</i> is * split on whitespace as if ` ' were specified. * * If the <i>limit</i> parameter is omitted, trailing null fields are should I create another issue to discuss about the documentation change?
If no need I will commit it.
Actions