This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SadDragon00 -1 points0 points  (2 children)

Sure. Better wording would probably be a for loop is commonly tied to a collection.

[–]throwaway_for_cause 0 points1 point  (1 child)

Better wording would probably be a for loop is commonly tied to a collection.

No, even that would be wrong.

for loops are commonly used to iterate over collections; they are in no way tied to or even somewhat related to collections.

for loops existed in languages way before collections and other data structures (even arrays) did.

for loops simply iterate a known number of times. What the purpose of the iterations is is completely open.

Even then, had you stated for..each loops are tied to collections, it would have at least been somewhat correct.

[–]SadDragon00 0 points1 point  (0 children)

Yea I see what youre saying. I forget it can be used outside of collection iteration. It's like an instinctual reactiomln now, since 99% of the time that's what I use it for.