this post was submitted on 17 Mar 2025
1255 points (99.6% liked)

Programmer Humor

34426 readers
509 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] formulaBonk@lemm.ee 44 points 1 day ago (14 children)

Reminds me of the days before ai assistants where people copy pasted code from forums and then you’d get quesitions like “I found this code and I know what every line does except this ‘for( int i = 0; i < 10; i ++)’ part. Is this someone using an unsupported expression?”

[–] idiomaddict@lemmy.world 6 points 1 day ago (5 children)

I’m less knowledgeable than the OOP about this. What’s the code you quoted do?

[–] Moredekai@lemmy.world 38 points 1 day ago (1 children)

It's a standard formatted for-loop. It's creating the integer variable i, and setting it to zero. The second part is saying "do this while i is less than 10", and the last part is saying what to do after the loop runs once -‐ increment i by 1. Under this would be the actual stuff you want to be doing in that loop. Assuming nothing in the rest of the code is manipulating i, it'll do this 10 times and then move on

[–] Fermion@feddit.nl 5 points 1 day ago

I would also add that usually i will be used inside the code block to index locations within whatever data structures need to be accessed. Keeping track of how many times the loop has run has more utility than just making sure something is repeated 10 times.

load more comments (3 replies)
load more comments (11 replies)