Foreach loops on static arrays error message

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 6 02:16:00 PDT 2017


On Thursday, 6 July 2017 at 09:11:44 UTC, Ola Fosheim Grøstad 
wrote:
> ubyte[256] data;
>
> if  (data.length > 0) {
>    ubyte i = 0;
>    do {
>         writeln(i);
>     } while ((++i) != cast(ubyte)data.length);
> }

You also need to add an assert before the if to check that the 
last index can be represented as an ubyte. So probably not worth 
it.




More information about the Digitalmars-d mailing list