0
Why
Why remove the variables x=x+3 to x +=3 Wont this cause problems later?
7 Answers
+ 7
x += 3 is just a short form of x = x + 3.
It's up to you which one would you prefer.
+ 5
John Adair No it doesn't assume the answer is the same with variable.
This form: x += 3
means the current value of x will be added by 3 and the answer will be the NEW value of x.
+ 2
And what problems would it cause.
x=x+3 is equivalent to x+=3.
+ 1
x=x+3 and x+=3 both are one and the same...none of them will cause problem
Its on u what u use...
except x+=3 looks good and its shorter( *-*just one character shorter)
0
it assumes the answer and the variable are the same
0
i finish the module one and it is saying 12/13 and wont let me move on. -_-
0
x+=3 works and is widely used in most, if not all modern programming languages and with all operators (-=, /= etc.). It's just a compact way to write x=x+3 or x+3=x in order to save you some typing. If you don't like it, you don't have to use it. But you should definitely know what it means.