Instance Method


Removes and returns the key-value pair at the specified index.


@discardableResult mutating func remove(at index: Dictionary<Key, Value>.Index) -> Dictionary<Key, Value>.Element



The position of the key-value pair to remove. index must be a valid index of the dictionary, and must not equal the dictionary’s end index.

Return Value

The key-value pair that correspond to index.


Calling this method invalidates any existing indices for use with this dictionary.

Complexity: O(n), where n is the number of key-value pairs in the dictionary.

See Also

Removing Keys and Values

func filter((Dictionary<Key, Value>.Element) -> Bool) -> [Key : Value]

Returns a new dictionary containing the key-value pairs of the dictionary that satisfy the given predicate.

func removeValue(forKey: Key) -> Value?

Removes the given key and its associated value from the dictionary.

func removeAll(keepingCapacity: Bool)

Removes all key-value pairs from the dictionary.