6.6 Boolean Logical Operators
Swift also provides a set of so-called logical operators designed to return Boolean true or false values. These operators both return Boolean results and take Boolean values as operands. The key operators are NOT (!), AND (&&) and OR (||).
The NOT (!) operator simply inverts the current value of a Boolean variable, or the result of an expression. For example, if a variable named flag is currently true, prefixing the variable with a ‘!’ character will invert the value to false:
var flag = true // variable is true
var secondFlag = !flag // secondFlag set to false
The OR (||) operator returns true if one of its two operands evaluates to true, otherwise it returns false. For example, the following code evaluates to true because at least one of the expressions either side of the OR operator is true:
if (10 < 20) || (20 < 10) {
print("...