Signed-unsigned comparisons in Phobos
Timon Gehr
timon.gehr at gmx.ch
Fri Aug 12 06:14:33 PDT 2011
On 08/12/2011 03:08 PM, bearophile wrote:
> 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
But some people seem to strongly dislike it though. It is a bit
unfortunate that you don't currently get the same functionality by using
retro.
More information about the Digitalmars-d
mailing list