---
title: "withMutableElements(_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/perclothvertexdata/withmutableelements(_:)"
---

# withMutableElements(_:)

Provides mutable access to the per-vertex data within a callback.

## Declaration

```swift
mutating func withMutableElements<Result>(_ callback: @_lifetime(0: copy 0) (inout MutableSpan<ElementType>) -> Result) -> Result
```

## Parameters

- `callback`: A closure that receives a mutable span over the per-vertex data.

## Return Value

Return Value The value returned by callback.

## Discussion

Discussion The provided span is only valid for the lifetime of the callback.

## See Also

### Accessing vertex data

- [vertexCount](realitykit/perclothvertexdata/vertexcount.md)
- [withElements(_:)](realitykit/perclothvertexdata/withelements(_:).md)
- [mutableElements](realitykit/perclothvertexdata/mutableelements.md)
