1.

What Is The Significance Of “?” In Swift?

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 = "Singh"

let name : String = middleName ?? lastName

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 = "Singh"

let name : String = middleName ?? lastName



Discussion

No Comment Found