【发布时间】:2020-09-28 20:04:30
【问题描述】:
protocol A {
associatedtype T
var t: T { get }
}
protocol B: A where T == Int {}
var b: B? = nil // Protocol 'B' can only be used as a generic constraint
// because it has Self or associated type requirements.
有没有办法创建扩展协议(B) 将具体类型分配给基本协议的(A) 关联类型,并通过这样做“删除”关联类型要求, 并成为没有关联类型的协议,不仅可用作通用约束?
【问题讨论】: