reduce string ranges
Christian Kamm
kamm-incasoftware at removethis.de
Wed Jun 4 21:51:53 PDT 2008
Brian Myers wrote:
> The following:
>
> int main(char[][] args)
> {
> string[] tstarr = ["one", "two", "three"];
> writefln(reduce!("a ~ b")("", tstarr));
> }
>
> gives the following error message:
>
> c:\dmd\bin\..\src\phobos\std\algorithm.d(289): Error: functions cannot
> return static array invariant(char[0u])
This is just the old problem that string literals are static arrays. Reduce
expects its return type to have the same type as the first argument, which
is invariant(char[0]) in your case. Replace "" by ""[] and the code
compiles.
More information about the Digitalmars-d
mailing list