<!--
{
  "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/Set/removeFirst()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sh11removeFirstxyF"
  },
  "title" : "removeFirst()"
}
-->

# removeFirst()

Removes the first element of the set.

```
@discardableResult mutating func removeFirst() -> Element
```

## Return Value

A member of the set.

## Discussion

Because a set is not an ordered collection, the “first” element may not
be the first element that was added to the set. The set must not be
empty.

> Complexity: Amortized O(1) if the set does not wrap a bridged `NSSet`.
> If the set wraps a bridged `NSSet`, the performance is unspecified.

---

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)