<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/UniqueArray/init(capacity:copying:)-5tkhn",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s11UniqueArrayV8capacity7copyingAByxGSiSg_qd__tc7ElementQyd__RszSTRd__lufc"
  },
  "title" : "init(capacity:copying:)"
}
-->

# init(capacity:copying:)

Creates a new array with the specified initial capacity, holding a copy
of the contents of a given sequence.

```
init(capacity: Int? = nil, copying contents: some Sequence<Element>)
```

## Parameters

`capacity`

The storage capacity of the new array, or nil to allocate
just enough capacity to store the contents.

`contents`

The sequence whose contents to copy into the new array.

---

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)