Skip to content

Instantly share code, notes, and snippets.

@aruld
Created October 19, 2011 18:29
Show Gist options
  • Save aruld/1299216 to your computer and use it in GitHub Desktop.
Save aruld/1299216 to your computer and use it in GitHub Desktop.
Dart forEach() on a Map
main() {
Map<String, int> map = {
'one': 1,
'two': 2,
'twelve': 12};
void iterateMapEntry(key, value) {
map[key] = value;
print('$key:$value');//string interpolation in action
}
map.forEach(iterateMapEntry);
}
@nixoncode
Copy link

What about the Index?

@mr-muhammad-rehan
Copy link

What about the Index?
int i=0;
void iterateMapEntry(key, value) {
map[key] = value;
print('$key:$value at $i');//string interpolation in action
i++;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment