DEV Community

Reynaldi
Reynaldi

Posted on

Daily Tips 1: Augmented Assignments

This is my 1st Daily Tips for programmer.

Many developers, especially junior developer when they dealing with simple math operation they will be doing something like this:
Alt Text

There's no wrong with that code above. But we can simplify with Augmented Assignments. Basically, an Augmented assignment is generally used to replace a statement where an operator takes a variable as one of its arguments and then assigns the result back to the same variable.

Instead of assigning x variable with x = x + 1 we can make them more clean like this.
Alt Text

So, how?

Let's see other simple math operation

Alt Text

Top comments (0)