About foreach loops
Caligo
iteronvexor at gmail.com
Wed Jun 15 07:35:33 PDT 2011
You can create a temporary if you like:
foreach(i; 0..10){
int ii = i + 1;
writeln(ii, " ");
}
Which outputs:
1 2 3 4 5 6 7 8 9 10
The problem with trying to "fix" foreach is that it would create
problems of its own. The following code would not behave correctly:
foreach(i; 0..10){
if(i & 1)
i += 1;
writeln(i, " is even.");
}
not to mention all the code that's already using foreach.
More information about the Digitalmars-d
mailing list