Swift difference between uppercase "I" and lowercase "I"

While playing on the Swift playground, I noticed that Self with capital "S" is available along with the lower case Self . Is there any difference between the two? If so, what are used for these two, especially for Self ?

+44
swift self
Jan 09 '15 at 15:24
source share
2 answers

Self refers to the type of current β€œthing” inside the protocol (which corresponds to the protocol). For an example of its use, see Function func returns Self .

The only official documents I have found for Self are in the Associated Protocol in Swift Programming. This is surprisingly not described in sections on protocols or nested types.

+47
Jan 09 '15 at 15:49
source share

in the protocol and extension declaration use Self else self

 extension protocolName where Self: UIView { func someFunction() { self.layer.shadowColor = UIColor.red.cgColor } } 
+4
Dec 10 '16 at 12:34
source share



All Articles