What is the difference between this, which does not seem to work
`
const Ntrend = 169;
local test = array(Ntrend,[0,0]);
`
and this, which does work
`
const Ntrend = 169;
local test = array(Ntrend,[0,0]);
for(local a=0;a<Ntrend;a+=1){
test[a] = [0,0];//it seems to be necessary to pre-fill the array
}
`
I test it with this code and what I found is the entire array is filled with the last element I write to it unless I loop through and fill the array with [0,0] first. I don’t see the difference but the result is different.
for(local a=0;a<Ntrend;a+=1){ local b = 1.2 * a; test[a][1] = b;// } server.log("TEST") ; server.log(http.jsonencode(test));
wrong output is this, 201.6 is the last value written
[ [ 0, 201.6 ], [ 0, 201.6 ], [ 0, 201.6 ], [ 0, 201.6 ]… and so on
correct output is
[ [ 0, 0 ], [ 0, 1.2 ], [ 0, 2.4 ], [ 0, 3.6 ], [ 0, 4.8 ], [ … and so on