for loop
Max Klyga
max.klyga at gmail.com
Sun Jan 22 05:54:16 PST 2012
On 2012-01-22 16:23:36 +0300, RenatoL said:
> This works:
>
> import std.stdio;
> void main()
> {
> int x = 0;
> int y = 0;
> for(; ((x < 5) && (y < 5)); x++, y ++)
> {
> writeln("x + y = ", x + y);
> }
> }
>
> The question is easy: is it possible to insert x and y internally
> in the for header? that is something like C#
>
> for (int x = 0, int y = 0; .....)
>
> this doesn't work in D.
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) { ... }
More information about the Digitalmars-d-learn
mailing list