-5

I am trying to follow the example in this post, and it was going smoothly until I ran into the lines of code with -= and += calls.

I believe this might be some sort of misprint in expressions that are supposed to update the object on the RHS of = according to some condition.

Unfortunately, interpreting this expression is key in getting what the code is doing, and guessing defeats the purpose.

Do these fragments of code or operators make any sense?

What was intended by the author?

Antoni Parellada
  • 4,253
  • 6
  • 49
  • 114

2 Answers2

2

x -= y, x += y and so forth are a shorthand way of writing x = x - y and x = x + y respectively.

bigsim
  • 132
  • 8
0

These are shorthands.

a -= b

means

a = a -b

The meaning of += should be fathomable now.

But, it seems that you might have gotten some Exception. In that case, feel free to post it, and your code.

serv-inc
  • 35,772
  • 9
  • 166
  • 188