【发布时间】:2016-09-04 18:03:26
【问题描述】:
var dict = Dictionary<Int64, ExternalInfo>()
为上面的字典创建一个扩展,比如
extension Dictionary where Key: IntegerLiteralConvertible, Value: ExternalInfo {
func contains(id: Int64) -> Bool {
return self[id] != nil
/* return self[3] != nil */ // No issue
}
mutating func remove(id: Int64) {
removeValueForKey(id)
}
}
这两个语句都会引发一些编译器级别的错误。需要做什么??
不能为索引为 'Dictionary 的值下标 输入“Int64”
【问题讨论】:
标签: swift dictionary