Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

dart
communitycreator

What is Map.forEach() in Dart?

Maria Elijah

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Map.forEach()

The Dart method forEach() is used to iterate over the entries of the Map.

Syntax


Map.forEach(void f(K key, V value));

Parameters

  • The forEach() method requires a key and a value. It applies f to each key-value pair of the map.

Code

The following code illustrates how to use the forEach() method in Dart.

void main() {
var map = {"title": "Map.forEach()", 'language': 'Dart', 'platform': 'Educative.io'};
// iterating using forEach()
map.forEach((k,v) => print('${k}: ${v}'));
}

RELATED TAGS

dart
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring