protocol ExampleProtocol {
associatedtype AType
func example(toString: AType)
}
class Example: ExampleProtocol {
}
class ExampleOverride: ExampleProtocol {
typealias AType = String
}
extension ExampleProtocol {
func example(toString: String) {
print("\(toString) From Base Example Protocol")
}
}
extension ExampleProtocol where Self: ExampleOverride {
func example(toString: String) {
print("\(toString) From Overriding Example Protocol Extension")
}
}
let example = Example()
let exampleOverride = ExampleOverride()
example.example(toString: "Test") //Test From Base Example Protocol
exampleOverride.example(toString: "Test") //Test From Overriding Example Protocol Extension