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.
Ola Fosheim Grøstad via Digitalmars-d Thu, 06 Jul 2017 02:21:35 -0700
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.