dimanche 13 octobre 2019

While loop coding pattern

Suppose I have this loop:

modified = true;
while(modified == true){
    modified = false;
    // do logic
    if (... condition...)
        modified = true;
}

I don't like that I initially have to declare the modified variable as true. The loop should terminate if in a round no more modifications have occured.

Aucun commentaire:

Enregistrer un commentaire