Stop Using i++ in Your Loops

Why ++i is often better than i++ (pre-increment vs. post-increment)

Devin Soni
Nov 6 · 2 min read
Photo by Safar Safarov on Unsplash

Introduction

If you’ve written a for-loop before, then you have almost definitely used i++ before to increment your loop variable.

However, have you ever thought about why you choose to do it like that?

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

Devin Soni

Written by

Software Engineering / Machine Learning

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade