Swift BasicsLesson 11Free preview
Swift Operators
This lesson is part of Swift · All levels
Summary
This lesson reviews the operators of arithmetic, comparison, logic, and assignment in Swift. Swift strictly prevents integer overflow by default (unless using a special overflow operator). In addition, Swift provides range operators and zero-coalescing operators.
Key points
- The standard arithmetic operator: +, -, *, /, %
- Swift does not allow overflow by default for memory security
- The Nile-Coalescing operator '??' gives the default value if the Optional is worth zero
- The ternary operator 'condition' if true: if false' provides a one-line expression branch
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.