Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions content/dart/concepts/map/terms/entries/entries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
Title: '.entries'
Description: 'Returns an iterable view of all key-value pairs in a map as MapEntry objects.'
Subjects:
- 'Computer Science'
- 'Code Foundations'
Tags:
- 'Dart'
- 'Data Structures'
- 'Properties'
CatalogContent:
- 'learn-dart'
- 'paths/computer-science'
---

In Dart, the **`.entries`** property returns an iterable view of a `Map`’s contents, where each element is a `MapEntry` containing a key and its corresponding value. This property is useful when both keys and values need to be accessed together during iteration.

## Syntax

```pseudo
myMap.entries
```

**Parameters:**

This property takes no parameters.

**Return value:**

Returns an `Iterable<MapEntry<K, V>>`, where each `MapEntry` represents a key–value pair from the map.

## Example 1: Iterating over keys and values together

In this example, `.entries` is used to iterate through a map and access both the key and value for each entry:

```dart
void main() {
Map<String, int> scores = {
'Alice': 95,
'Bob': 87,
'Charlie': 92
};

for (var entry in scores.entries) {
print('${entry.key}: ${entry.value}');
}
}
```

The above example produces the following output:

```shell
Alice: 95
Bob: 87
Charlie: 92
```