Logo

Programming-Idioms

History of Idiom 7 > diff from v130 to v131

Edit summary for version 131 by programming-idioms.org:
[Dart] Variable name x

Version 130

2022-08-26, 14:27:01

Version 131

2022-08-26, 14:35: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
indices traverse traversal
Extra Keywords
indices traverse traversal
Code
items.asMap().forEach((i, value) {
  print('index=$i, value=$value');
});
Code
items.asMap().forEach((i, x) {
  print('index=$i, value=$x');
});
Comments bubble
An alternative, but not really idiomatic.
Comments bubble
An alternative, but not really idiomatic.
Doc URL
https://api.dart.dev/stable/2.10.4/dart-core/List/asMap.html
Doc URL
https://api.dart.dev/stable/2.10.4/dart-core/List/asMap.html
Demo URL
https://dartpad.dev/0337a175b949727eb6ee32900d7e35fa
Demo URL
https://dartpad.dev/?id=01d954fd11e3d935cabaea59f171272e