我刚刚更新到 Xcode 10.2,我以前编译的扩展无法再编译:
extension Array where Element == StringProtocol? {
func joined(by separator: String = " ") -> String {
return compactMap { $0?.description }.joined(separator: separator)
}
}
著名的Protocol 'StringProtocol' can only be used as a generic constraint because it has Self or associated type requirements
错误现在出现了……
有人可以告诉我发生了什么吗?我还没有迁移到 Swift 5,只是打开了我的项目。
我已更改为:
extension Array where Element == CustomStringConvertible?
但我想了解为什么会发生这种变化......有什么想法吗?