Eray Diler Eray Diler - 1 year ago 159
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


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.