R
2

PSA: My kid's broken toy last week made me see loops in a new way

My son's remote control car stopped turning left, and I had to check each wire connection one by one. I was doing the same thing over and over, and it hit me that this is exactly what a 'for' loop does in code. I was manually running the loop instead of letting the computer do it. Has anyone else had a simple moment like that where a coding concept just clicked from real life?
4 comments

Log in to join the discussion

Log In
4 Comments
xena886
xena88626d ago
Wait, @jakem98 said a for loop checks all wires at once? That's not how it works at all, lol. The loop still goes through each wire one after another, just like Quinn said. It's a single process checking each item in a list, not a bunch of checks happening together. The speed makes it seem instant, but it's still step by step. That's a pretty big mix-up about basic code logic.
7
jakem98
jakem981mo ago
But isn't a for loop more like checking all the wires at once?
6
quinn958
quinn95826d ago
Nah, a for loop is still checking one wire at a time, just really fast. It's still a step-by-step process, not all at once. The computer just does each step so quick it looks instant. That's the whole trick of it, really. Makes you think it's doing everything together when it's not.
6
patriciabrown
Man, I hope you at least got paid overtime for being the computer.
3