Removes the given key and its associated value from the dictionary.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
Parameters
key
The key to remove along with its associated value.
Return Value
The value that was removed, or nil
if the key was not present in the dictionary.
Discussion
If the key is found in the dictionary, this method returns the key’s associated value. On removal, this method invalidates all indices with respect to the dictionary.
If the key isn’t found in the dictionary, remove
returns nil
.
Complexity: O(n), where n is the number of key-value pairs in the dictionary.