+ 1
Total += number;
what is the meaning of "+=" ? how it works?
3 Respuestas
+ 14
x += 2 is the same as x = x + 2
You can also you -=, *=, /=
It's just faster to type and easier to read.
+ 3
It serves to reduce the code and avoid redundant.
ex.
i += 5;
it's equal to
i = i + 5;
+ 3
The basic assignment operator is "=".
Whereas the the above mentioned assignment operator is shorthand assignment operator.
Let us assume two operands "a" and "b".
Let us see the actual working of this operator some module.
Let "a+=b" be the actual task to be performed.
It is equivalent to a=a+b. That is the two operand "a","b" gets added and stored in "a" operand.
Similarly
"a-=b" implies a=a-b, //Subtraction assignment operator
"a*=b" implies a=a*b, //Multiplication assignment operator
"a/=b" implies a=a/b, //Division assignment operator
"a^=b" implies a=a^b, // Bitwise XOR assignment operator
and so on.