Dart-programming-list-replacerange-function
提供:Dev Guides
List.replaceRange()関数
dart:coreライブラリのListクラスは、リストアイテムを変更する* replaceRange()*関数を提供します。 この関数は、指定された範囲内の要素の値を置き換えます。
List.replaceRange()関数を使用するための構文は以下のとおりです-
List.replaceRange(int start_index,int end_index,Iterable <items>)
どこで、
- Start_index -置換を開始するインデックス位置を表す整数。
- End_index -置換を停止するインデックス位置を表す整数。
- <items> -更新された値を表す反復可能なオブジェクト。
次の*例*は同じことを示しています-
void main() {
List l = [1, 2, 3,4,5,6,7,8,9];
print('The value of list before replacing ${l}');
l.replaceRange(0,3,[11,23,24]);
print('The value of list after replacing the items
between the range [0-3] is ${l}');
}
次の output が生成されるはずです-
The value of list before replacing [1, 2, 3, 4, 5, 6, 7, 8, 9]
The value of list after replacing the items between
the range [0-3] is [11, 23, 24, 4, 5, 6, 7, 8, 9]