Signed-unsigned comparisons in Phobos
bearophile
bearophileHUGS at lycos.com
Fri Aug 12 06:08:14 PDT 2011
Marco Leise:
> Just remember that reverse loops are written like this:
>
> for (size_t i = x.length; i-- > 0; ) {...}
Thankfully in D there is foreach_reverse :-)
import std.stdio;
void main() {
auto array = [10, 20, 30];
for (size_t i = array.length; i-- > 0; )
writeln(i, " ", array[i]);
foreach_reverse (i, item; array)
writeln(i, " ", item);
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list