Eray Diler Eray Diler - 2 years ago 215
Swift Question

Distinction in Swift between uppercase "Self" and lowercase "self"

While playing in a Swift playground I noticed that

, with capital "S", is available along with the lowercase
. Is there any difference between them? If so, what are usages for these two, especially for

Answer Source

Self refers to the type of the current "thing" inside of a protocol (whatever is conforming to the protocol). For an example of its use, see Protocol func returning Self.

The only official docs I've found for Self is in Protocol Associated Type Declaration in The Swift Programming Language. It surprisingly is not documented in the sections on protocols or on nested types.

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