---
title: "removeAll(keepingCapacity:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/contiguousarray/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.
