diff options
| author | Adam Bard <github@adambard.com> | 2017-02-01 13:57:30 -0800 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-01 13:57:30 -0800 | 
| commit | 6e00874000b43418b64bf9f4b92cac38d9bf9475 (patch) | |
| tree | 3c8f0c0848d62874ce7eddeafaace2bfed723a93 | |
| parent | 79004c5b4ad998a150d61e3147639a2c09015a37 (diff) | |
| parent | a19efad7fc938c2e505582a3541a3c083d0f85c8 (diff) | |
Merge pull request #2564 from technikyle/technikyle-patch-1
[swift\en] Added nil-coalescing operator
| -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 | 
