Skip to content

Files

Latest commit

82eac14 · Jan 15, 2018

History

History
10 lines (7 loc) · 714 Bytes

2.5 - Nil-Coalescing Operator.md

File metadata and controls

10 lines (7 loc) · 714 Bytes

The nil-coalescing operator a ?? b, unwraps an optional a if it contains a value, and returns b if it is nil. a must always be an optional type, and b must be the same type as the type stored in a.

It is shorthand for the following:

a != nil ? a! : b

Previous Note| Back To Contents | Next Note