76
Compound Assignment Operators
Swift 4 provides compound assignment operators that combine assignment (=) operator with another operator. One example of compound assignment operator is the addition assignment operator (+=)
For example,
Here, a += 20 is short form for a = a + 20. Addition and assignment operators are combined into one operator that performs both tasks at the same time.
Note: The compound assignment operators don’t return a value. For example, you can’t write let b = a += 20.
Next TopicComparison Operators