Last active
August 29, 2015 14:27
-
-
Save an0/a3e2952017b5a7a0d4d0 to your computer and use it in GitHub Desktop.
Self Referential Limitation or Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class Foo { | |
// static let _sharedInstance = self.init() // Why not work? | |
static let _sharedInstance = Foo() | |
static func sharedInstance() -> Self { | |
return _sharedInstance // Why 'Foo' is not convertible to 'Self'? It is `static` so `Self` can only be `Foo`. In fact since the class is final there won't be any subclasses at all. | |
// return self.init() // Why this works? | |
} | |
required init() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment