---
title: "replace(_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowlevelbufferresource/replace(_:)"
---

# replace(_:)

Replaces the buffer synchronously on the CPU. The buffer’s contents are unspecified; you must populate the buffer with valid data.

## Declaration

```swift
final func replace<R, E>(_ body: @_lifetime(0: copy 0) (inout MutableRawSpan) throws(E) -> R) throws(E) -> R where E : Error, R : ~Copyable
```

## Parameters

- `body`: A closure that receives a mutable span over the buffer’s bytes to fully populate.

## Discussion

Discussion note: Any error thrown by body.

## See Also

### Replacing buffer contents

- [replace(commandBuffer:)](realitykit/lowlevelbufferresource/replace(commandbuffer:).md)
