我想把 struct 存储在数组中,访问并更改 for 循环中 struct 的值。
struct testing {
var value:Int
}
var test1 = testing(value: 6 )
test1.value = 2
// this works with no issue
var test2 = testing(value: 12 )
var testings = [ test1, test2 ]
for test in testings{
test.value = 3
// here I get the error:"Can not assign to 'value' in 'test'"
}
如果我将结构改为类,它就可以工作。有人能告诉我如何更改结构的值吗。