7 ms·
I use ++i in for loops because pre-incrementing is the semantically correct option. I've never understood why i++ came into favor; can anyone shine some light
by avigesaa 17y ago
I use ++i in for loops because pre-incrementing is the semantically correct option. I've never understood why i++ came into favor; can anyone shine some light on it for me?
- lincolnq 17y agoMy hypothesis: it has better rhythm -- the repetition of 'i' at the beginning of each piece of the for loop makes it nice and easy to remember. I bet people would tend to learn this when they were first learning how to code and then never change because it never caused them any problems.