var a ="0050"var b = aa ="2330"print(b)// "0050"// String 賦值是複製一份 StringfuncresetData(input: Int){ input =""// Error 無法編譯,input 預設是 let}
structStock{var name: String="0050"}var a =Stock()var b = aa.name ="2330"print(b.name)// "0050"// struct 賦值是複製一份 structfuncresetData(input: Stock){ input.name =""// Error 無法編譯,input 預設是 let}
classStock{var name: String="0050"}var a =Stock()var b = aa.name ="2330"print(b.name)// "2330"// class 賦值是用同一份 classfuncresetData(input: Stock){ input.name ="Null"}resetData(input: a)print(a.name)// class 傳值是用同一份 class,可以在方法內修改