From 3e755219ec0ff9579c440cbcab87213610ef781d Mon Sep 17 00:00:00 2001 From: Muntazir-sd Date: Mon, 15 Dec 2025 17:48:53 +0530 Subject: [PATCH 1/2] Add Dart Map .addAll() term entry --- .../concepts/map/terms/add-all/add-all.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 content/dart/concepts/map/terms/add-all/add-all.md diff --git a/content/dart/concepts/map/terms/add-all/add-all.md b/content/dart/concepts/map/terms/add-all/add-all.md new file mode 100644 index 00000000000..e2b477f9ffd --- /dev/null +++ b/content/dart/concepts/map/terms/add-all/add-all.md @@ -0,0 +1,65 @@ +--- +Title: '.addAll()' +Description: 'Adds all key-value pairs from another Map to an existing Map.' +Subjects: + - 'Computer Science' + - 'Data Science' +Tags: + - 'Dart' + - 'Map' + - 'Methods' +CatalogContent: + - 'learn-dart' + - 'paths/computer-science' +--- + +In Dart, the **`.addAll()`** method adds all key-value pairs from another `Map` into an existing `Map`. This is commonly used when merging maps or inserting multiple entries at once. + +If a key from the source map already exists in the target map, its value will be replaced by the value from the source map. + +## Syntax + +```pseudo +mapVariable.addAll(otherMap) +``` + +- `mapVariable`: The map that will receive the new entries. +- `otherMap`: A map containing key-value pairs to be added. + +**Parameters:** + +- `otherMap`: A `Map` whose key and value types must match those of the target map. + +**Return value:** + +- `void`: This method does not return a value; it modifies the map in place. + +## Example + +The following example demonstrates how `.addAll()` can be used to merge two maps: + +```dart +void main() { + Map inventory = { + 'Apples': 5, + 'Bananas': 3 + }; + + Map newItems = { + 'Oranges': 4, + 'Grapes': 10 + }; + + inventory.addAll(newItems); + + print(inventory); +} +``` + +**Output:** + +The output of this code is as follows: + +```shell +{Apples: 5, Bananas: 3, Oranges: 4, Grapes: 10} +``` From 06798edc81a9d80263db8a5286c45642dcccd29c Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Wed, 17 Dec 2025 15:57:54 +0530 Subject: [PATCH 2/2] Revise .addAll() documentation for accuracy Updated the description and parameters for clarity. --- content/dart/concepts/map/terms/add-all/add-all.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/content/dart/concepts/map/terms/add-all/add-all.md b/content/dart/concepts/map/terms/add-all/add-all.md index e2b477f9ffd..be7ce79515a 100644 --- a/content/dart/concepts/map/terms/add-all/add-all.md +++ b/content/dart/concepts/map/terms/add-all/add-all.md @@ -1,6 +1,6 @@ --- Title: '.addAll()' -Description: 'Adds all key-value pairs from another Map to an existing Map.' +Description: 'Adds all key-value pairs from another `Map` into the current map.' Subjects: - 'Computer Science' - 'Data Science' @@ -23,16 +23,15 @@ If a key from the source map already exists in the target map, its value will be mapVariable.addAll(otherMap) ``` -- `mapVariable`: The map that will receive the new entries. -- `otherMap`: A map containing key-value pairs to be added. +`mapVariable` is the `Map` object to which new key–value pairs will be added. **Parameters:** -- `otherMap`: A `Map` whose key and value types must match those of the target map. +- `otherMap`: A map whose key–value pairs are added to `mapVariable`. If a key already exists, its value is overwritten. **Return value:** -- `void`: This method does not return a value; it modifies the map in place. +This method returns `void`. The original map is modified in place. ## Example @@ -56,8 +55,6 @@ void main() { } ``` -**Output:** - The output of this code is as follows: ```shell