I can only assume it's an infinite loop.
Can I leave out any of the three expressions in a for loop? Is there a default for each when omitted?
Yes, it's an infinite loop.
Examples:
for (; ;) { }
(aka: The Crab)
while (true) { }
do { } while (true)
It is indeed an infinite loop.
Under the hood the compiler/jitter will optimize this to (effectively) a simple JMP operation.
It's also effectively the same as:
while (true)
{
}
(except that this is also optimized away, since the (true) part of a while expression usually requires some sort of comparison, however in this case, there's nothing to compare. Just keep on looping!)
Yes, that's an infinite loop. You can leave out any of the three expressions, though in my experience it's typically either the first or all 3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With