protocol 可以透過 associated type 宣告型別代號,而代號的真正型別則可從遵從 protocol 的型別,protocol 的 extension,遵從 protocol 的型別的 extension,在宣告 associatedtype 時給予初始值等六種方法決定。
1 由遵從 protocol 的型別推理。
protocol Princess { associatedtype HandyMan var…