for ranges

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 22 08:46:06 PST 2015


Russel Winder:

> However for BigInt:
>
> 	for(i; two..n + one)
>
> the loop starts at 0 and just keeps on going. This is clearly 
> not good.

It works for me:

void main() {
     import std.stdio, std.bigint;

     immutable BigInt one = 1;
     immutable BigInt two = 2;
     uint n = 100;

     foreach (immutable i; two .. n + one)
         i.writeln;
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list