Skip to content

Instantly share code, notes, and snippets.

@aruld
Created October 19, 2011 18:29
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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);
}
@max6188
Copy link

max6188 commented Jun 4, 2018

Guena!

@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