April 2026
Intermediate
683 pages
25h 29m
English
Throughout the book, we’ve introduced many Swift operators. For example, + is used to add two numbers and == is used to check for equality. Using extensions, you can add support for new operators for a data type. In this section, you’ll see various examples of operator overloading.
Let’s start with a refresher of some of the arithmetic and Boolean operators supported in Swift, as listed in Table 11.1.
|
Operator |
Meaning |
Example |
|---|---|---|
|
+ |
Addition |
a + b |
|
- |
Subtraction |
a - b |
|
* |
Multiplication |
a * b |
|
/ |
Division |
a / b |
|
% |
Remainder |
a % b |
|
&& |
AND |
a && b |
|
|| |
OR |
a || b |
Table 11.1 Some Arithmetic and Boolean Operators
Using ...
Read now
Unlock full access