Skip to content

Instantly share code, notes, and snippets.

@cprovatas
Last active October 20, 2018 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cprovatas/75e290996eaee447e2bc75fa2ccf54bb to your computer and use it in GitHub Desktop.
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
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