What Is Shorthand Operator?
These are operators used to assign values with operations by using short syntax.
How to use the shorthand operator?
For using a shorthand operator, we need to put the operator just before the assignment operator to perform the operation.
For Example, x += y or x *= y or x -= y or x /= y or x |= y
What Is OR Assignment and AND Assignment Operator?
- |= (OR assignment operator): If X(boolean) and Y(boolean) are both false then X remains false otherwise X is assigned true.
- &= (AND assignment operator): If X(boolean) and Y(boolean) are both true then X remains true otherwise X is assigned false.