can't zip a char[5], string[5], real[5]

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 21 07:11:20 PDT 2015


On Wednesday, 21 October 2015 at 14:06:54 UTC, Shriramana Sharma 
wrote:
> import std.stdio, std.range;
> void mywrite(char [5] chars, real[5] vals)
> {
>     static string [5] fmts = ["%9.4f, ", "%9.4f; ", "%3d, ", 
> "%3d, ",
> "%3d\n"];
>     foreach (e; zip(chars, fmts, vals)) write(e[0], " = ",
> e[1].format(e[2]));
> }
>
> Compiling gives:
[...]
> I would have thought there would be no problem in creating a 
> zip of three arrays of equal length. What's the problem here?

Static arrays are not ranges. You can't popFront them. Try 
slicing them: chars[], fmts[], vals[]


More information about the Digitalmars-d-learn mailing list