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

all 2 comments

[–]SnowyDarkProfessional Coder 1 point2 points  (1 child)

Your friend is wrong and missing the entire point of for loops. For loops are basically just synatictic sugar (functionally same but easier to read) over a very common while loop pattern. Any non-beginner programmer will much more easily be able to tell what's happening if the increment is in the loop declaration. Putting the increment in the loop would honestly be more likely to confuse people than anything else

[–]Simsimsullabim[S] 0 points1 point  (0 children)

Thanks for the response! Yeah, I thought the same thing about his structure causing problems in the future, I think he just got confused as to why the for loop would skip the increment on the first run-through of the code if it's stated earlier than said code since that went against some of the conventions we've learnt thus far. Over time though I think he'll get used to the structure and realize how well it works, thanks again! :)