Last active
October 20, 2018 22:28
-
-
Save cprovatas/75e290996eaee447e2bc75fa2ccf54bb to your computer and use it in GitHub Desktop.
Access current type by calling Self instead of manually calling <current type>.self
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
protocol TypeReflectable { | |
var `Self`: Self.Type { get } | |
static var `Self`: Self.Type { get } | |
} | |
extension TypeReflectable { | |
var `Self`: Self.Type { | |
return type(of: self) | |
} | |
static var `Self`: Self.Type { | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment