Skip to content

Instantly share code, notes, and snippets.

@jgallagher
Created January 15, 2015 16:27
Show Gist options
  • Select an option

  • Save jgallagher/de9fd68e00eda76e1e64 to your computer and use it in GitHub Desktop.

Select an option

Save jgallagher/de9fd68e00eda76e1e64 to your computer and use it in GitHub Desktop.
Don't use Swift Dictionary indices after you change the dictionary
var d: [Int:Int] = Dictionary(minimumCapacity: 64)
d[1] = 1
let idx = d.startIndex
println(d[idx])
for i in 1 ..< 63 {
d[1 + 64*i] = 1+64*i
}
println("d[1] is still \(d[1]), but d[idx] is now \(d[idx])")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment