In fast structures, they are copied by value when they are bound to a new variable. So, when you assign a a1value in a dictionary, it actually creates a copy. Here is the line I'm talking about:
var a1 = d1["a"]!
After calling this line, there are actually two lists: the list that is referenced d1["a"], and the list that is referenced a1. Thus, only the second list changes when you call the following line:
a1.append("s1")
, ( "a" d1). , .
Option1: d1.
var d1 = [String : [String]]()
d1["a"] = [String]()
d1["a"]?.append("s1")
println(d1)
2: "a" d1.
var d1 = [String : [String]]()
d1["a"] = [String]()
var a1 = d1["a"]!
a1.append("s1")
d1["a"] = a1
println(d1)
, .