DEV Community

Discussion on: What are the use cases of using optional for loop statements?

Collapse
 
jonhaddow profile image
Jon Haddow

Never done this before, but I could imagine a scenario where I'd want to break out of a loop half way through the iteration, if a condition is met. Then if that was the only way to break out, then omitting the condition makes sense to me.

Collapse
 
pandaquests profile image
Panda Quests

Then just use an infinite loop, e g. While (true) { check condition }