set

fun <Root, Value> Root.set(keyPath: WritableKeyPath<Root, Value>, value: Value): Root

Replaces keyPath's focus and returns the resulting root.

For a value-style data-class path, the result is a copy and must be assigned by the caller. For a reference-writable path, the returned value is the same, now-mutated instance.


operator fun <Root : Any, Value> Root.set(path: ReferenceWritableKeyPath<Root, Value>, value: Value)

In-place assignment shorthand for a reference-writable path.

Its parameter is deliberately named path, rather than keyPath: an explicit root.set(keyPath = ..., value = ...) always selects the copy-returning set overload, whereas root[referencePath] = value selects this Kotlin operator convention.