Swift Operators - Part Three Flashcards
Operators
An operator is a special symbol or phrase that you use to check, change or combine values.
3 Kinds of Operators
Unary, Binary, Ternary
Binary Operators
Operate on Two Targets (1 + 1): the two ā1sā are Operands
Expression
A combination of an operator with Operands is called an Expression.
Binary Operators
Addition: +
Subtraction: -
Division: /
Multiplication: *
Remainder: %
Long Division - Remainder (Modulo Operator).
Assignment Operator (=)
The assignment operator denoted by the equal to symbol initializes or updates the value of one operand.
The operand on the left hand side is updated by the value on the right-hand side.
Comparison Operators:
Equal To: ==
Not Equal To: !=
Greater Than: >
Lesser Than: <
Operator Precedence
Left to Right:
Higher Precedence Level (150):
Multiplication: *
Division: /
Remainder: %
Precedence Level (140):
Addition: +
Subtraction: -
Unary Operators
Work with one operand only.
NOTE:
Always place the increment operator to the left of the operand.