Created
October 19, 2011 18:29
-
-
Save aruld/1299216 to your computer and use it in GitHub Desktop.
Dart forEach() on a Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
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
What about the Index?