I am doing some ruby exercises and it said I need to go back and rewrite the script with +=
shorthand notations.
This exercise deals primarily with learning new methods. The problem is, I have no idea what +=
means when I tried to look it up online.
+= Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand. C += A is equivalent to C = C + A.
The += operator in C is one of the language's compound assignment operators. It is essentially a shorthand notation for incrementing the variable on the left by an arbitrary value on the right. The following two lines of C code are identical, in terms of their effect on the variable z: z = z + y; // increment z by y.
The Python += operator adds two values together and assigns the final value to a variable. This operator is called the addition assignment operator. This operator is often used to add values to a counter variable that tracks how many times something has happened.
+=
is a shorthand operator.
someVar += otherVar
is the same as
someVar = someVar + otherVar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With