for loop

bearophile bearophileHUGS at lycos.com
Sun Jan 22 09:08:46 PST 2012


Max Klyga:

> If you want to declare and initialize several variables in the for 
> loop, you can do it if they are of the same type:
> 
> for (int x = 0, y = 0; ...; .++x, ++y) { ... }

And if you need different types this sometimes is enough:

void main() {
    for (auto x = 0, y = 0.0; x < 10; x++, y++) {
    }
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list