Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@writeascript your prof may have been talking about for-each loops (eg. The for loop in Python). That's still not true in quite a few cases, eg. for looping over an infinite data structure, or an iterator that never ends.
-
@RememberMe Plus that this is the form from K&R, and also the only form of infinite loop that will pass Lint.
-
git-gud14067y@LastDigitOfPi java checking in - not sure if other languages handle that differently, but as soon as i overflows the loop ends.
-
Root797677ySo. very. wrong.
0) for(;;); // hello?
1) for(i=0; i<12; i--); // incorrect iterators
2) for(i=0; j<12; i++); // incorrect conditions
3) for(i=0; i<12; i++) { i=0; } // modifying the accumulator within the loop
4) for(i=0; i<12; ); // whoops!
5) for(i=0; ; i++); // stolen condition
6) for(i=0; i==0; i); // yawn.
7) for(i=~3; ~i; i=~i); // infinite flopping nonsense ~
Your instructor needs to stop attending/giving lectures and start coding again.
Related Rants
uni prof: "you can't make an infinite for loop. Infinite loopsnare only possible with while loops"....
I think it's not what he meant, but it was a while ago and I forgot the context, but multiple students made a 'what the fuck?' noise.
rant
shitpeoplesay
while loops
for loops
infinite loop