<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Array/init(repeating:count:)-5y5f0",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SmsE9repeating5countx7ElementQz_Sitcfc::SYNTHESIZED::s:Sa"
  },
  "title" : "init(repeating:count:)"
}
-->

# init(repeating:count:)

Creates a new collection containing the specified number of a single,
repeated value.

```
init(repeating repeatedValue: Self.Element, count: Int)
```

## Parameters

`repeatedValue`

The element to repeat.

`count`

The number of times to repeat the value passed in the
`repeating` parameter. `count` must be zero or greater.

## Discussion

Here’s an example of creating an array initialized with five strings
containing the letter *Z*.

```
let fiveZs = Array(repeating: "Z", count: 5)
print(fiveZs)
// Prints "["Z", "Z", "Z", "Z", "Z"]"
```

---

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)