[Issue 5977] String splitting with empty separator
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 18 02:46:30 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=5977
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #5 from bearophile_hugs at eml.cc 2013-11-18 02:46:27 PST ---
After this pull:
https://github.com/D-Programming-Language/phobos/pull/1502
This program:
void main() {
import std.string, std.stdio;
auto r = split("a test", "");
pragma(msg, typeof(r));
r.writeln;
}
Gives:
string[]
["a", " ", "t", "e", "s", "t"]
And this program:
void main() {
import std.algorithm, std.stdio;
auto r = splitter("a test", "");
r.writeln;
}
Gives the same output:
["a", " ", "t", "e", "s", "t"]
It's different from what Python does:
>>> "a test".split("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: empty separator
But it's much better than an infinite loop, it can be often useful, and I think
it's acceptable, so I close down the issue.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list