sdasdadas sdasdadas - 1 year ago 109
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download