Why splitter() doesn't work?
Mehrdad
wfunction at hotmail.com
Sun Oct 14 13:03:51 PDT 2012
On Sunday, 14 October 2012 at 19:26:37 UTC, Peter Alexander wrote:
> 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.
Yup, but why does it need slicing?
More information about the Digitalmars-d
mailing list