是这样的
protocol A {
var intCollection: CollectionType<Int> { get }
}
Run Code Online (Sandbox Code Playgroud)
要么
protocol A {
typealias T: CollectionType where T.Generator.Element == Int
var intCollection: T
}
Run Code Online (Sandbox Code Playgroud)
可以在Swift 2.1中使用吗?
Swift 4的更新
Swift 4现在支持此功能!在这里阅读更多内容