std.algorithm.splitter improovement?

Marco Leise Marco.Leise at gmx.de
Sat Dec 14 17:25:27 PST 2013


Am Sat, 14 Dec 2013 18:20:13 +0100
schrieb "bearophile" <bearophileHUGS at lycos.com>:

> 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

Somehow I cannot say this makes me happy. I totally thought
there was only one splitter and it has to be used with a
delimiter. You are right that the OP didn't say which version
he used. The result made it clear in the end. So the solution
to this is "use the other splitter".

-- 
Marco



More information about the Digitalmars-d-learn mailing list