2. Which operator would you use to provide a default value if the value of the optional turns out to be nil?

?

!

[CORRECT ANSWER] ??

&

Hint

Results

Congratulations! Correct Answer.

You Answered: None. If you took the test, your answer will show up here.

Correct Answer: ??

Explanation

When an optional value is nil, you can conveniently return a default value by using the ?? operator (Nil Coalescing Operator). var final = chosen ?? default - here if chosen is nil, then the default will get used.

Take the Test

Take the complete test on this topic. You will be able to review answers to questions and get a test score.