有人可以解释这段代码出了什么问题吗?从代码中(至少我自己)可以预期,在运行此代码后,数字列表看起来像numbers = [[0], [1]],但它看起来像numbers= [[0,1], [0,1]].
void main() {
int n = 2;
List<List<int>> numbers = new List.filled(n, []);
for(int i=0; i<n; i++)
for(int j=i+1; j<n; j++ ){
numbers[i].add(0);
numbers[j].add(1);
}
}
Run Code Online (Sandbox Code Playgroud)
PS:这不仅仅是一种心理锻炼.