Short expressions – simple math expressions (+ = …)
: Is A=A+1 the same as A += 1 ?
The short answer is YES
If you are an old style RPG programmer, evolving into a modern RPG programmer you will frequently see this style of coding when looking at modern RPGLE code examples:
$variable += 1;
$variable -= 1;
$variable *= 2;
$variable /= 2;
This math notation simply means “take the right side and apply it to the left side of the value”
$variable += 1 could also be written at $variable = $variable + 1
Or we could negate a value by typing
$variable *= -1
I like it and have used this style for years.
But remember, don’t mix up up += with =+
$variable += 1will add one to the value $variable
$variable =+ 1will set the value of $variable to ‘+1’