Shortcut Operators Flashcards

1
Q

Shortcut operators
It’s time for the next set of operators that make a developer’s life easier.

A

Very often, we want to use one and the same variable both to the right and left sides of the = operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If op is a two-argument operator (this is a very important condition) and the operator is used in the following context:

A

variable = variable op expression

t can be simplified and shown as follows:

variable op= expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

i = i + 2 * j

A

⇒ i += 2 * j

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

var = var / 2

A

⇒ var /= 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

rem = rem % 10

A

⇒ rem %= 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

j = j - (i + var + rem)

A

⇒ j -= (i + var + rem)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

x = x ** 2

A

⇒ x **= 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly