Speaking of protocols
45 sec read
Here is another nice read about protocols; method overriding, in particular. Some examples:
// Our generic class.
class DBStore<T> {
func store(a: T) {
store T
}
}
protocol Storeable { }
protocol Interim { }
// Hello, generic Method Overloading by Protocol:
class DBStore<T> {
func store<T: Storeable>(a: T) {
// Store T.
}
func store<T: Interim>(a: T) {
// Compress T.
}
// And more advanced:
func store<T: Storeable>(a: T) where T: Equatable {
// Store T.
}
}