- Mastering macOS Programming
- Stuart Grimshaw
- 41字
- 2021-07-02 22:54:17
Nil-coalescing operator
The nil-coalescing operator assigns a value if it is not nil, or an alternative if it is:
let title = possibleString ?? "Untitled"
We check whether possibleString is nil; if it is, we assign "Untitled" to the title constant.