<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Dictionary/remove(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SD6remove2atx3key_q_5valuetSD5IndexVyxq__G_tF"
  },
  "title" : "remove(at:)"
}
-->

# remove(at:)

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

## 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

The key-value pair that correspond to `index`.

## Discussion

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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)