sdasdadas sdasdadas - 7 months ago 50
Swift Question

Do Optionals default to nil?

What is the initial value of the

variable if no constructor is provided?

class Example {
weak var delegate: Bool?


Yes it is automatically set to nil if unassigned.

From Apple:

If you define an optional variable without providing a default value, the variable is automatically set to nil for you