8 ms·
Basically what I am saying is while should be mostly off limits. But yes if you end up in a loop you have some sort of counter/null checks or way out if you en
by drawkbox 9y ago
Basically what I am saying is while should be mostly off limits.
But yes if you end up in a loop you have some sort of counter/null checks or way out if you end up in a constant/recursive loop.
Never leave open the possibility of a lock due to being stuck in a loop.
- ajuc 9y agoYou want to write "cat" equivalent. How do you do the loop? I think for loops should be limited to iteration over collections, or repeating sth known number of times. There are cases when you need to decide if you want to continue iteration on the fly, and while loop is the perfect tool for that. Also while loop is arguably less error-prone than for loop: can't swap clauses because there's just one, can't write "," instead of ";" by mistake.