---
title: "repeatElement(_:count:)"
framework: swift
role: symbol
role_heading: Function
path: "swift/repeatelement(_:count:)"
---

# repeatElement(_:count:)

Creates a collection containing the specified number of the given element.

## Declaration

```swift
func repeatElement<T>(_ element: T, count n: Int) -> Repeated<T>
```

## Parameters

- `element`: The element to repeat.

## Return Value

Return Value A collection that contains count elements that are all element.

## Discussion

Discussion The following example creates a Repeated<Int> collection containing five zeroes: let zeroes = repeatElement(0, count: 5) for x in zeroes {     print(x) } // 0 // 0 // 0 // 0 // 0

## See Also

### Special-Use Collections

- [CollectionOfOne](swift/collectionofone.md)
- [EmptyCollection](swift/emptycollection.md)
- [KeyValuePairs](swift/keyvaluepairs.md)
- [DictionaryLiteral](swift/dictionaryliteral.md)
