Google News
logo
Swift - Quiz(MCQ)
How can you make a property optional in Swift?
A)
You have to declare a question mark ? in the code to make a property optional
B)
You have to declare a question mark & in the code to make a property optional
C)
You have to declare a question mark ?? in the code to make a property optional
D)
None of the above

Correct Answer :   You have to declare a question mark ?? in the code to make a property optional


Explanation : We have to declare a question mark ?? in the code to make a property optional. If a property doesn't have a value, then the symbol ? helps to avoid the runtime error.

Advertisement