Logo

Programming-Idioms

History of Idiom 7 > diff from v129 to v130

Edit summary for version 130 by programming-idioms.org:
New Dart implementation by user [programming-idioms.org]

Version 129

2022-03-03, 10:24:35

Version 130

2022-08-26, 14:27:01

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Variables
i,x,items
Variables
i,x,items
Extra Keywords
indices traverse traversal
Extra Keywords
indices traverse traversal
Imports
import 'package:collection/collection.dart';
Code
items.forEachIndexed((i, x) {
  print('index=$i, value=$x');
});
Doc URL
https://api.flutter.dev/flutter/package-collection_collection/IterableExtension/forEachIndexed.html
Origin
https://stackoverflow.com/a/59447850/871134
Demo URL
https://dartpad.dev/?id=44a908e369cf0541659d3b75640c3fb0