---
title: "removeAll(keepingCapacity:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/array/removeall(keepingcapacity:)"
---

# removeAll(keepingCapacity:)

Removes all elements from the array.

## Declaration

```swift
mutating func removeAll(keepingCapacity keepCapacity: Bool = false)
```

## Parameters

- `keepCapacity`: Pass true to keep the existing capacity of the array after removing its elements. The default value is false.

## Discussion

Discussion note: O(n), where n is the length of the array.

## See Also

### Removing Elements

- [remove(at:)](swift/array/remove(at:).md)
- [removeFirst()](swift/array/removefirst().md)
- [removeFirst(_:)](swift/array/removefirst(_:).md)
- [removeLast()](swift/array/removelast().md)
- [removeLast(_:)](swift/array/removelast(_:).md)
- [removeSubrange(_:)](swift/array/removesubrange(_:)-8may1.md)
- [removeSubrange(_:)](swift/array/removesubrange(_:)-9twou.md)
- [removeAll(where:)](swift/array/removeall(where:)-5k61r.md)
- [popLast()](swift/array/poplast().md)
