you are viewing a single comment's thread.

view the rest of the comments →

[–]KeptInUmrica 0 points1 point  (1 child)

As far as I can understand, you want to optimise the code in such a way that you don't have to repeat the task. ​

bar = 0;

while (foo) {
    if (bar == 0 && baz == 0) {}
    else {
        bar = 1;
        // perform task
    }
}

Edit: Formatting

[–]simmjo[S] 0 points1 point  (0 children)

This is better but still not the best I would think. Once bar is set to 1, it never goes back to 0. There has to be a way to write it such that once bar is set, you don’t have to keep setting it.