Why would we use a mathematical assignment operator?

Thank you MTF :octopus:

1 Like

Thank you. This is actually very logical.

I am relatively new to coding, but my theory is that it is simply a convenient short-hand way to express the value. Writing x = x+1 gets old pretty quick. Over time it become quicker to write x += 1. Once you get used to it, I also find it easier to read.

Under the hood, they are two different operations.

1 Like

loved the quote, saving it. Although I wouldโ€™ve appreciated if you gave a little peek into the real answer too :slight_smile:
Is it because itโ€™s easier to use this form?

The difference between a = a + n and a += n is primarily that the latter is an in place operation, meaning that while possible, the operation takes place in the same slot in memory; the former is a new assignment so will be in a different slot.

i think i get it now. thanks!

Well explained. Thank you