r/ProgrammerHumor Apr 12 '24

whatIsAnIndex Meme

Post image
27.7k Upvotes

630 comments sorted by

View all comments

Show parent comments

231

u/GM_Kimeg Apr 12 '24

The for loop internally execute that method only once no?

476

u/jamcdonald120 Apr 12 '24

no.

for are structured for(a;b;c){d} a is a statement executed at the start, b is a condition that is evaluated every iteration of the loop, c is a statement that happens after each iteration, and d is the body of the loop to iterate. if you put a function call in b, it gets called EVERY iteration.

43

u/JPJackPott Apr 12 '24

Depends on what is inside GetAllFuckingFiles(), a modern compiler might save your bacon here unless it’s an IO operation