Using useless object.self.self.. or Class.self.self.. is ever need?
This is a Postfix Self Expression according to the Swift reference:
A postfix self expression consists of an expression or the name of a type, immediately followed by
The first form evaluates to the value of the expression. For example, x.self evaluates to x.
The fact that you can write
.self indefinitely is just a side effect of this definition. Since
x.self is an expression itself, you can add
.self to it too. And you can do this forever.
That doesn't mean you should though.
These do the same thing:
let x = 10 let x = 10
Hopefully you'd agree that the second one reads better. Similarly,
.self is generally redundant. According to this discussion, it seems like
.self is really just a legacy from Objective-C. IMO it also makes syntaxes like the identity key path (
\.self) "make more sense".