.removeAll()
KyraThompson73 total contributions
Published Apr 26, 2023Updated May 5, 2023
Contribute to Docs
The .removeAll()
method will remove all key-value pairs from a dictionary.
Syntax
dictionaryInstance.removeAll()
Note: The .removeAll()
method takes no parameters.
Example
var bookShelf = ["Moby Dick": "Herman Melville","The Odyssey": "Homer","Pride and Prejudice": "Jane Austen"]bookShelf.removeAll()print(bookShelf)
In the example above, all key-value pairs in the bookShelf
dictionary are removed. This will output an empty dictionary:
[:]
All contributors
- KyraThompson73 total contributions
- SophiieDucks2 total contributions
- Christine_Yang271 total contributions
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.