Swift Developer Question:

Explain me what Is The Significance Of “?” In Swift?

Tweet Share WhatsApp

Answer:

The question mark (?) is used during the declaration of a property. If the property does not hold a value, the question mark (?) helps to avoiding application errors.

Example looks like -

class Employee {

var certificate : [Certificates]?

}

let employee = Employee();

Example 2 -

let middleName : String? = nil

let lastName : String = "Muhammad"

let name : String = middleName ?? lastName

Download Swift Developer PDF Read All 39 Swift Developer Questions
Previous QuestionNext Question
Tell me what do you do when you realize that your App is prone to crashing?Tell us your preference when writing UI's? Xib files, Storyboards or programmatic UIView?