---
title: "remove(at:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/dictionary/remove(at:)"
---

# remove(at:)

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

## Declaration

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

## Parameters

- `index`: 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

Return Value The key-value pair that correspond to index.

## Discussion

Discussion Calling this method invalidates any existing indices for use with this dictionary. note: O(n), where n is the number of key-value pairs in the dictionary.

## See Also

### Removing Keys and Values

- [filter(_:)](swift/dictionary/filter(_:).md)
- [removeValue(forKey:)](swift/dictionary/removevalue(forkey:).md)
- [removeAll(keepingCapacity:)](swift/dictionary/removeall(keepingcapacity:).md)
