In Swift 4, an operator is special symbol or phrase which is used to check, change or combine values. It tells the compiler to perform specific mathematical or logical manipulations. For example, the addition operator (+) adds two numbers, the logical AND operator (&&) combines two Boolean values etc.
Swift 4 supports most of the standard C language operators. It enhances some capabilities to remove some common coding errors.
Classification of Operators on Terminology
There are three types of operators: unary, binary and ternary.
Unary operator: Unary operators are used on a single target (like -a). Unary prefix operators appear immediately before their target (such as !b). Unary postfix operators appear immediately after their target (such as c!).
Binary Operator: Binary operators are used when we have to operate on two targets. (like 2 + 3) and are infix because they appear in between their two targets.
Ternary Operator: Ternary operators operate on three targets. Like C language, Swift also has only one ternary operator called the ternary conditional operator (a ? b : c).
Note: The values associated with operator are operands. For example, in the expression 1 + 2, the + symbol is a binary operator and its two operands are the values 1 and 2.
The most common built-in operators in Swift 4