This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |