Dart更新列表的索引

Dart可以修改List中專案的值。 換句話說,可以重寫列表項的值。 如以下示例代碼 -

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

上面的示例使用索引0更新List項的值。代碼的輸出將為 -

[123, 2, 3]

上一篇: Dart列表 下一篇: Dart映射