Logo

Programming-Idioms

History of Idiom 7 > diff from v97 to v98

Edit summary for version 98 by programming-idioms.org:
[Dart] +DemoURL

Version 97

2020-11-05, 10:41:36

Version 98

2020-11-05, 14:32:08

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
traverse traversal
Extra Keywords
traverse traversal
Code
items.asMap().forEach((i, value) {
  print('index=$i, value=$value');
});
Code
items.asMap().forEach((i, value) {
  print('index=$i, value=$value');
});
Comments bubble
An alternative, but not really idiomatic.
Comments bubble
An alternative, but not really idiomatic.
Demo URL
https://dartpad.dev/0337a175b949727eb6ee32900d7e35fa