---
title: "writable"
description: "Call [block] with a writable state record for [snapshot] of the given record. It is assumed that
this is called for the first state record in a state object. If the snapshot is read-only calling
this will throw."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
public inline fun <T : StateRecord, R> T.writable(
    state: StateObject,
    snapshot: Snapshot,
    block: T.() -> R,
): R
```


Call `block` with a writable state record for `snapshot` of the given record. It is assumed that
this is called for the first state record in a state object. If the snapshot is read-only calling
this will throw.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
public inline fun <T : StateRecord, R> T.writable(state: StateObject, block: T.() -> R): R
```


Call `block` with a writable state record for the given record. It is assumed that this is called
for the first state record in a state object. A record is writable if it was created in the
current mutable snapshot.



