Skip to content

Instantly share code, notes, and snippets.

var mydict = ["a" : [1, 2, 3]]
mydict["a"]!.append(4)
// compiles and seems to work
var mydict2 : [String : Any] = ["a" : [1, 2, 3]]
mydict2["a"]!.append(4) // does not work. thats expected
(mydict2["a"] as! [Int]).append(4)
// does not work, unexpected for me. stackoverflow says that's because forcecasting value types
// creates a copy which is immutable
// how do I append to the array?