---
title: "initializeElement(at:to:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/slice/initializeelement(at:to:)"
---

# initializeElement(at:to:)

Initializes the element at index to the given value.

## Declaration

```swift
func initializeElement<Element>(at index: Int, to value: Element) where Base == UnsafeMutableBufferPointer<Element>
```

## Parameters

- `index`: The index of the element to initialize
- `value`: The value used to initialize the buffer element’s memory.

## Discussion

Discussion The memory underlying the destination element must be uninitialized, or Element must be a trivial type. After a call to initialize(to:), the memory underlying this element of the buffer slice is initialized.
