我试图让Array<String>
符合Hashable
,在Swift 3预览版6中:
extension Array: Hashable where Element: Hashable {
public var hashValue: Int {
var hashValue = 0
for element in self {
hashValue ^= element.hashValue
}
return hashValue
}
}
var data = Dictionary<Array<String>, Any>()
但是我收到以下错误并且不明白为什么:
ERROR at line 4, col 1: extension of type 'Array' with constraints cannot have an inheritance clause
extension Array: Hashable where Element: Hashable {
^
如何使阵列可以缓存?