How do you use the new compound assignment operators?

I’ve seen a reply from a topic somewhere that mentioned these compound assignment operators, and I’m pretty excited based on how short it could make some of your code. How do you use them?

I’m on mobile right now so I cant really answer this myself by messing around on studio

1 Like

You use them the same you would use, say these:

local a = 0
a = a + 1

local b = 11
a = a - 1

You can shorten these to

a += 1
b -= 1

and a will be incremented by 1, b decremented by 1

Luau also introduces *=, /=, %=, ^=, ..= which are multiplication, division, modulus, exponentation, and concatenation respectively.


Thanks! Time go to go shorten a lot of my code tomorrow lol

1 Like