---
title: "update(fromContentsOf:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unsafemutablebufferpointer/update(fromcontentsof:)"
---

# update(fromContentsOf:)

Updates the buffer’s initialized memory with every element of the source.

## Declaration

```swift
func update(fromContentsOf source: some Collection<Element>) -> UnsafeMutableBufferPointer<Element>.Index
```

## Parameters

- `source`: A collection of elements to be used to update the buffer’s contents.

## Return Value

Return Value An index one past the index of the last element updated.

## Discussion

Discussion Prior to calling the update(fromContentsOf:) method on a buffer, the first source.count elements of the buffer’s memory must be initialized, or the buffer’s Element type must be a trivial type. The buffer must reference enough initialized memory to accommodate source.count elements. The returned index is one past the index of the last element updated. If source contains no elements, the returned index is equal to the buffer’s startIndex. If source contains as many elements as the buffer can hold, the returned index is equal to the buffer’s endIndex. note: The memory regions referenced by source and this buffer may overlap. note: self.count >= source.count
