std.algorithm.splitter improovement?

bearophile bearophileHUGS at lycos.com
Sat Dec 14 09:20:13 PST 2013


Marco Leise:

> Not at all, the documentation explicitly states:
>
>   assert(equal(splitter("hello  world", ' '), [ "hello", "", 
> "world" ]));

I didn't see the ' ' in the OP code, sorry.

A test:


void main() {
     import std.stdio, std.string, std.algorithm;
     auto s = "hello  world";
     s.split().writeln;
     std.array.splitter(s).writeln;
     s.splitter(' ').writeln;
}


The output seems OK:

["hello", "world"]
["hello", "world"]
["hello", "", "world"]

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list