summaryrefslogtreecommitdiffhomepage
path: root/swift.html.markdown
diff options
context:
space:
mode:
authorSean Nam <namsangwoo1@gmail.com>2017-02-09 17:10:03 -0800
committerSean Nam <namsangwoo1@gmail.com>2017-02-09 17:10:03 -0800
commit5254804c1ccf51fb3c3c500a7095dd8408371837 (patch)
treecade605f3e011f8ac0d46ef74380c632e5502f99 /swift.html.markdown
parent52ff8f41e4ef9de074081b5ef22c5dfa4dd86f0a (diff)
parent7f0fff0adf38fb47b36da4a8c319c6c9c28c546d (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'swift.html.markdown')
-rw-r--r--swift.html.markdown5
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