Operators and conditions summary
You’ve made it to the end of the third part of this series, so let’s summarize:
- Swift has operators for doing arithmetic and for comparison; they mostly work like you already know.
- There are compound variants of arithmetic operators that modify their variables in place:
-=, and so on.
- You can use
else if to run code based on the result of a condition.
- Swift has a ternary operator that combines a check with true and false code blocks. Although you might see it in other code, I wouldn’t recommend using it yourself.
- If you have multiple conditions using the same value, it’s often clearer to use
- You can make ranges using
... depending on whether the last number should be excluded or included.
Need to know Objective-C fast?
I wrote a book dedicated to teaching Objective-C to developers who already know Swift – it's the fastest way to get up to speed!