のプロトコルがありassociatedType
ます。typealias
プロトコル拡張でそのタイプのデフォルトを指定したいと思います。これは、特定のクラスから継承するクラスに対してのみ行われます。
protocol Foo: class {
associatedtype Bar
func fooFunction(bar: Bar)
}
プロトコル拡張:
extension Foo where Self: SomeClass {
typealias Bar = Int
func fooFunction(bar: Int) {
// Implementation
}
}
コンパイラはそれを不平を言い'Bar' is ambiguous for type lookup in this context
ます。私も迅速な本で役立つものを見つけることができませんでした。