by reltuk · 4y ago · 0 comments
When using unsigned ints for backward iteration, I'm partial to looping as:
for (i = size - 1; i < size; i--) {
...
}
since it has so much symmetry with forward iteration. for(uint32_t i = 0; i < length; ++i) {
i = (length - 1) - i;
// ...
}
Much easier for me to understand, making it less likely to mess anything up. foreach (i; 0 .. length)
D takes care of selecting the correct type for `i`.Probably formatted i-- > 0. Concise and reads (once used to it anyway) something like i decrementing to zero.