Skip to content

Commit c6cc545

Browse files
Revise .map() method documentation
Updated the description and improved clarity of the .map() method documentation.
1 parent e2578ec commit c6cc545

File tree

1 file changed

+16
-6
lines changed
  • content/dart/concepts/map/terms/map

1 file changed

+16
-6
lines changed

content/dart/concepts/map/terms/map/map.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Title: '.map()'
3-
Description: '.map() transforms each key-value pair in a Dart Map into a new Map.'
3+
Description: 'Creates a new map by transforming each keyvalue pair of an existing map using a provided function.'
44
Subjects:
55
- 'Computer Science'
66
- 'Web Development'
@@ -13,18 +13,28 @@ CatalogContent:
1313
- 'paths/computer-science'
1414
---
1515

16-
In Dart, the `.map()` method is used to create a new map by transforming each key-value pair of an existing map using a provided function.
16+
In Dart, the **`.map()`** method creates a new map by transforming each keyvalue pair of an existing map using a provided function.
1717

1818
## Syntax
1919

2020
```pseudo
2121
myMap.map((key, value) => MapEntry(newKey, newValue))
2222
```
2323

24-
- `myMap`: The map whose entries are to be transformed.
25-
- `key`: The key from the original map.
26-
- `value`: The value associated with the key.
27-
- `MapEntry`: Represents a single key-value pair in the new map.
24+
Here, `myMap` is the map whose entries are to be transformed.
25+
26+
**Parameters:**
27+
28+
- A function that takes two arguments:
29+
- `key`: The key from the original map.
30+
- `value`: The value associated with that key.
31+
- The function must return a `MapEntry`, which defines the key–value pair in the new map.
32+
33+
**Return value:**
34+
35+
The `.map()` method returns a new `Map` containing the transformed key–value pairs.
36+
37+
> **Note:** The original map remains unchanged.
2838
2939
## Example 1
3040

0 commit comments

Comments
 (0)