What does "+=" (plus equals) mean in Ruby?

ruby

Solution

num += -1

is an equivalent of

num = num + -1

or, for this example

num = num - 1

which, in turn, can be written as

num -= 1

Problem

I'm going through a Ruby tutorial and I can't grasp the += statement. Google isn't helping, "Ruby +=" only searches for "Ruby". Help is appreciated. Sample: ``` num = -10 num += -1 if num < 0 puts num #=> -11 ```

Original source

Related problems