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

# remove(at:)

Removes and returns the character at the specified position.

## Declaration

```swift
@discardableResult mutating func remove(at i: String.Index) -> Character
```

## Parameters

- `i`: The position of the character to remove. i must be a valid index of the string that is not equal to the string’s end index.

## Return Value

Return Value The character that was removed.

## Discussion

Discussion All the elements following i are moved to close the gap. This example removes the hyphen from the middle of a string. var nonempty = "non-empty" if let i = nonempty.firstIndex(of: "-") {     nonempty.remove(at: i) } print(nonempty) // Prints "nonempty" Calling this method invalidates any existing indices for use with this string.

## See Also

### Removing Substrings

- [remove(at:)](swift/string/remove(at:)-5g0wm.md)
- [removeAll(keepingCapacity:)](swift/string/removeall(keepingcapacity:).md)
- [removeAll(where:)](swift/string/removeall(where:).md)
- [removeFirst()](swift/string/removefirst().md)
- [removeFirst(_:)](swift/string/removefirst(_:).md)
- [removeLast()](swift/string/removelast().md)
- [removeLast(_:)](swift/string/removelast(_:).md)
- [removeSubrange(_:)](swift/string/removesubrange(_:).md)
- [removeSubrange(_:)](swift/string/removesubrange(_:)-8maxn.md)
- [removeSubrange(_:)](swift/string/removesubrange(_:)-9twng.md)
- [drop(while:)](swift/string/drop(while:).md)
- [dropFirst(_:)](swift/string/dropfirst(_:).md)
- [dropLast(_:)](swift/string/droplast(_:).md)
- [popLast()](swift/string/poplast().md)
