目录

更新索引(Updating The Index)

Dart允许修改List中项目的值。 换句话说,可以重写列表项的值。 以下example说明了相同的情况 -

void main() { 
   List l = [1, 2, 3]; 
   l[0] = 123; 
   print(l); 
}

上面的示例使用索引0更新List项的值。代码的输出将为 -

[123, 2, 3]
↑回到顶部↑
WIKI教程 @2018