Categories
|
Test: Swift - Nil Coalescing Operator 1. var city: String?; display = city ?? “No City” - what is the value of display?
Results Congratulations! Correct Answer. You Answered: None. If you took the test, your answer will show up here. Correct Answer: No city Explanation The Nil Coalescing Operator (??) returns the default value (to its right) if the value to its left is nil. Since city has not been set to a non-nil value, display will get “No City”Take the Test Take the complete test on this topic. You will be able to review answers to questions and get a test score.
Take the Test
Question 1 of 5
Test is Based on this Article
This article talks about the Nil Coalescing Operator (??) in Swift.
|
Test on Nil Coalescing Operator for Optionals.
|
|
More Articles With Similar Tags
|
Test on Nil Coalescing Operator for Optionals.
|
This article talks about unwrapping the optionals in Swift implicitly and the circumstances where you would use this functionality.
|
This article discusses the safer ways of unwrapping an optional in Swift that includes Optional Binding.
|
This article talks about optional chaining in swift where multiple optionals can be chained together and fail gracefully by returning nil when one of them is nil.
|
Summary of three operators (?, !, ??) used in optionals in Swift.
|
|
|
|
|