Swift Object reference to array?

Viewed 4692

I probably missed an important information about swift. I have a map contains a key / swift array pair. I changed the array and the array inside the map was not changed. Could someone explain what is going on? Thanks!

var map = [String:[String]]()
var list = [String]()
map["list"] = list //output: "["list": []]\n"
print(map)

list.append("test")
print(list)  //output: "["test"]\n"
print(map)   //output: "["list": []]\n"
4 Answers
Related