Skip to content

Commit b4a358e

Browse files
committed
Add Dart Map .entries documentation
1 parent 93f7d7f commit b4a358e

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
Title: '.entries'
3+
Description: 'Returns an iterable collection containing all key-value pairs as MapEntry objects in a map.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Code Foundations'
7+
Tags:
8+
- 'Dart'
9+
- 'Data Structures'
10+
- 'Properties'
11+
CatalogContent:
12+
- 'learn-dart'
13+
- 'paths/computer-science'
14+
---
15+
16+
In Dart, the **`.entries`** property returns an iterable collection containing all key-value pairs as `MapEntry` objects in a map. This allows you to iterate over both keys and values together.
17+
18+
## Syntax
19+
20+
```pseudo
21+
myMap.entries
22+
```
23+
24+
- `myMap`: The map name that needs to be iterated.
25+
26+
## Example
27+
28+
The following example demonstrates the usage of the `.entries` property:
29+
30+
```dart
31+
void main() {
32+
Map<String, int> scores = {
33+
'Alice': 95,
34+
'Bob': 87,
35+
'Charlie': 92
36+
};
37+
38+
for (var entry in scores.entries) {
39+
print('${entry.key}: ${entry.value}');
40+
}
41+
}
42+
```
43+
44+
The above example produces the following output:
45+
46+
```shell
47+
Alice: 95
48+
Bob: 87
49+
Charlie: 92
50+
```

0 commit comments

Comments
 (0)