I'm seeing: += a lot. What does it mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I'm seeing: += a lot. What does it mean?

25th Feb 2017, 1:51 PM
Thomas Molendijk
Thomas Molendijk - avatar
4 Answers
+ 22
It means sum and assignment. Example: a = 1; a += 1; // result: a == 2 It is the same as: a = a + 1;
25th Feb 2017, 1:57 PM
Igor Makarsky
Igor Makarsky - avatar
+ 18
x += 5 is shorthand of x = x + 5
25th Feb 2017, 1:52 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 2
Thank you so much for your quick response!
25th Feb 2017, 1:59 PM
Thomas Molendijk
Thomas Molendijk - avatar
+ 1
That's an assignment operator, which assign sum of left and right operands to left one. So x += y is equivalent to x = x + y. These are similar operators: -= *= /= %= etc...
25th Feb 2017, 2:04 PM
Twelfty
Twelfty - avatar