Skip to content

Commit

Permalink
[Term Entry] Dart Maps: .remove()
Browse files Browse the repository at this point in the history
* Add formatting scripts

* Create new term entry for dart List.remove() method

* Update the entry for dart map.remove()

* Update description in remove.md entry

* Delete package.json

* Delete yarn.lock

* Update content/dart/concepts/map/terms/remove/remove.md

* Update content/dart/concepts/map/terms/remove/remove.md

* Update content/dart/concepts/map/terms/remove/remove.md

* Update content/dart/concepts/map/terms/remove/remove.md

* Minor changes

---------
  • Loading branch information
dancikmad committed May 14, 2024
1 parent 0a04ccf commit 091a053
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions content/dart/concepts/map/terms/remove/remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
Title: '.remove()'
Description: 'Removes the specified key and its associated value from a map.'
Subjects:
- 'Computer Science'
- 'Web Development'
Tags:
- 'Methods'
- 'Dart'
- 'Lists'
CatalogContent:
- 'learn-dart'
- 'paths/computer-science'
---

In Dart, the `.remove()` method removes the specified key and its associated value from a map. If the key-value pair is removed, it returns the value associated with the removed key. Otherwise, it returns `null` and the map remains unchanged.

## Syntax

```pseudo
map_name.remove(key)
```

- `map_name`: The name of the map to be checked.
- `key`: The entry key to be removed from the map.

## Example

In the following example, the `.remove()` method is used to remove en entry with the key `c` from a map:

```dart
void main() {
Map<String, int> myMap = {'a': 1, 'b': 2, 'c': 3};
print('Original Map: $myMap');
// Removing an entry with the key 'c' from the map
myMap.remove('c');
print('Map after removing the entry with the key "c": $myMap');
}
```

Here is the output for the above example:

```shell
Original Map: {a: 1, b: 2, c: 3}
Map after removing the entry with the key "c": {a: 1, b: 2}
```

0 comments on commit 091a053

Please sign in to comment.