---
title: "initialize(repeating:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/slice/initialize(repeating:)"
---

# initialize(repeating:)

Initializes every element in this buffer slice’s memory to a copy of the given value.

## Declaration

```swift
func initialize<Element>(repeating repeatedValue: Element) where Base == UnsafeMutableBufferPointer<Element>
```

## Parameters

- `repeatedValue`: The value with which to initialize this buffer slice’s memory.

## Discussion

Discussion The destination memory must be uninitialized or the buffer’s Element must be a trivial type. After a call to initialize(repeating:), the entire region of memory referenced by this buffer slice is initialized.
