标签: swift
var cacheDic = Dictionary<Int, Int>() if let _ = cacheDic[v] { cacheDic[v]? += 1 } else { cacheDic[v] = 1 }
如果v为空,则默认值为0。我可以简单地使用此cacheDic[v]? += 1。
cacheDic[v]? += 1