Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A type that can be initialized without any parameters.
/// Types that can be initialized without any parameters.
/// Useful if you need to accept an array of metatypes and then initialize them.
protocol EmptyInitializable {
init()
}
extension Int: EmptyInitializable {}
extension Int8: EmptyInitializable {}
extension Int16: EmptyInitializable {}
extension Int32: EmptyInitializable {}
extension Int64: EmptyInitializable {}
extension Double: EmptyInitializable {}
extension Float: EmptyInitializable {}
extension Float80: EmptyInitializable {}
extension String: EmptyInitializable {}
extension Dictionary: EmptyInitializable {}
extension Set: EmptyInitializable {}
extension NSString: EmptyInitializable {}
extension NSAttributedString: EmptyInitializable {}
extension NSImage: EmptyInitializable {}
extension NSURL: EmptyInitializable {}
extension NSColor: EmptyInitializable {}
extension NSSound: EmptyInitializable {}
extension NSFilePromiseProvider: EmptyInitializable {}
extension NSPasteboardItem: EmptyInitializable {}
extension URL: EmptyInitializable {
init() {
self.init(string: ".")!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment