diff options
-rw-r--r-- | swift.html.markdown | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/swift.html.markdown b/swift.html.markdown index b6554dc6..c17510b6 100644 --- a/swift.html.markdown +++ b/swift.html.markdown @@ -104,6 +104,11 @@ if let someOptionalStringConstant = someOptionalString { } } +// The nil-coalescing operator ?? unwraps an optional if it contains a non-nil value, or returns a default value. +var someOptionalString: String? +let someString = someOptionalString ?? "abc" +print(someString) // abc + // Swift has support for storing a value of any type. // For that purposes there is two keywords: `Any` and `AnyObject` // `AnyObject` == `id` from Objective-C |