【发布时间】:2014-06-26 18:19:06
【问题描述】:
有人能描述一下这是怎么可能的吗:
swift模板库中有以下内容:
protocol Collection : Sequence {
subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}
这没关系。
但是如果你写:
protocol Test : Sequence {
subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}
有编译错误:
“IndexType”不是“Self”的成员类型
我可以通过以下方式修复此错误:
protocol Test : Sequence {
typealias IndexType
subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}
但首先工作如何?
【问题讨论】: