Basic Operators
Nil-Coalescing Operator
The nil-coalescing operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil.
The expression a is always of an optional type. The expression b must match the type that is stored inside a.
The nil-coalescing operator is shorthand for the code below:
a != nil ? a! : b
Range Operators
let count = 10
for i in 1...count {
}
for i in 1..<count {
}
One-Sided Ranges
for name in names[2...] {
print(name)
}
for name in names[...2] {
print(name)
}