"For" infinite loop
Chris Cain
clcain at uncg.edu
Sat Aug 11 13:25:44 PDT 2012
On Saturday, 11 August 2012 at 20:00:40 UTC, bioinfornatics wrote:
> n this case why not using a while loop ?
You mean like this?
void main() {
ubyte i = 0;
do {
write(i, " ");
} while(i++ != 255);
}
or
void main() {
ubyte i = 0;
while(true) {
write(i, " ");
if(i++ == 255)
break;
}
}
?
It's kind of a personal preference on how you want to handle this
case, IMO. I think using a for loop how bearophile showed is more
typical. Most would argue going with the "standard" approach is
the most correct way ... but I almost like using a do-while in
this case.
More information about the Digitalmars-d-learn
mailing list