I'm using a 2 dimensional array to hold a (conceptual) grid of true/false states, and I'm experiencing different behavior depending on whether I use the fill2D method, or fill an Array with Arrays, and I don't understand why.
x = Array.fill(8, Array.fill(8, false));
x[0][0] = x[0][0].not;
x.postln; // the first element of all sub arrays is flipped
x = Array.fill2D(8, 8, false);
x[0][0] = x[0][0].not;
x.postln; // only x[0][0] is flipped
So I've solved my problem by using Array.fill2D, but I'm still curious why the behavior here is different.
FWIW, if you just explicitly set the state, i.e. use x[0][0] = false rather than x[0][0].not, the same thing happens.