---
title: "remove(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/set/remove(_:)-8p2tv"
---

# remove(_:)

Removes the specified element from the set.

## Declaration

```swift
@discardableResult mutating func remove(_ member: Element) -> Element?
```

## Parameters

- `member`: The element to remove from the set.

## Return Value

Return Value The value of the member parameter if it was a member of the set; otherwise, nil.

## Discussion

Discussion This example removes the element "sugar" from a set of ingredients. var ingredients: Set = ["cocoa beans", "sugar", "cocoa butter", "salt"] let toRemove = "sugar" if let removed = ingredients.remove(toRemove) {     print("The recipe is now \(removed)-free.") } // Prints "The recipe is now sugar-free."

## See Also

### Removing Elements

- [filter(_:)](swift/set/filter(_:).md)
- [remove(_:)](swift/set/remove(_:)-4d3i1.md)
- [removeFirst()](swift/set/removefirst().md)
- [remove(at:)](swift/set/remove(at:).md)
- [removeAll(keepingCapacity:)](swift/set/removeall(keepingcapacity:).md)
