Why splitter() doesn't work?

Peter Alexander peter.alexander.au at gmail.com
Sun Oct 14 12:26:32 PDT 2012


On Sunday, 14 October 2012 at 09:50:20 UTC, Mehrdad wrote:
> Why doesn't code like this work?
>
> chain(repeat("a").take(5), repeat("b").take(5)).splitter("b");

There's two versions of splitter, the version that splits a range 
using an element, and a version that splits a range using another 
range.

The chain you're using creates a range of strings, and you are 
splitting it using a string, so it appears you are going for the 
first version.

The signature for that version is:

auto splitter(Range, Separator)(Range r, Separator s)
if (is(typeof(ElementType!Range.init == Separator.init))
         && (hasSlicing!Range || isNarrowString!Range))

chain doesn't support slicing (and isn't a narrow string), so you 
can't split it using this function.


More information about the Digitalmars-d mailing list