【发布时间】:2014-10-17 15:24:21
【问题描述】:
是否可以在 Swift 中编写基于协议的扩展?
我知道我可以使用基类,但我不想这样做。
protocol SomeProtocol {
var numbers: [Int] { get set }
}
extentension T: SomeProtocol {
func sumarize() -> Int {
return self.numbers.reduce(0, +)
}
}
【问题讨论】:
-
我想,我的回答不是回答你的问题。也许你要找的是stackoverflow.com/questions/24047164/…