Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do people use i = i + 1 instead of i++? [closed]

I've seen that in a number of loops and increments. Instead of doing i++ they do i += 1. Why is this?

like image 534
David G Avatar asked Sep 05 '11 23:09

David G


2 Answers

Not all languages have ++ operator (python, for one)... Probably these people come from a background in one of those languages. Also some people feel that i++ is not very clear, especially since some languages treat i++ and ++i differently.

like image 131
SoapBox Avatar answered Sep 20 '22 15:09

SoapBox


Personal preference and style.

like image 34
Daniel A. White Avatar answered Sep 19 '22 15:09

Daniel A. White