Feature #3575 closed
String#split is inconsistent with empty string and negative limit
Added by Conrad.Irwin (Conrad Irwin) over 14 years ago.
Updated almost 5 years ago.
Description
Currently works like this:
"" . split ( "," , - 1 ) # => []
According to the documentation, blank fields should not be stripped when a negative offset is provided. I expect:
"" . split ( "," , - 1 ) # => [""]
Description updated (diff )
I think Ruby thinks "" has no fields, not one field which have empty string.
So, "".split(",", -1) should return [].
Documentation issue, maybe.
Category changed from core to doc
Assignee set to drbrain (Eric Hodel)
I will add a note to the documentation to cover the behavior of empty strings.
Status changed from Open to Assigned
Status changed from Assigned to Closed
% Done changed from 0 to 100
This issue was solved with changeset r35275.
Conrad, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
string.c (rb_str_split_m): Documented behavior of split on the empty
string. [ruby-trunk - Feature #3575 ]
Description updated (diff )
Also available in: Atom
PDF
Like 0
Like 0 Like 0 Like 0 Like 0 Like 0