我正在阅读 Apple 出版的 Swift 书籍。我有 XCode 7.2.1 下面的代码给出了编译错误。我在操场上使用了代码。
protocol Container {
associatedtype ItemType
mutating func append(item: ItemType)
var count: Int { get }
subscript(i: Int) -> ItemType { get }
}
您可以在页面的后半部分看到代码。
我不确定这是否是对代码的正确更改;但是当我将协议中的第一行从
associatedtype ItemType
至
typealias ItemType
错误消失了。