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

# initializeElement(at:to:)

Initializes the element at index to the given value.

## Declaration

```swift
func initializeElement(at index: UnsafeMutableBufferPointer<Element>.Index, to value: consuming 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 is initialized.
