Skip to content
Konjure / spatial intelligence

set

← Builtin reference

Replaces an existing record component on an entity.

Signature

func set(entity: Entity, component: C) -> Unit

C means a concrete type value. set requires that component to exist already and replaces it atomically; use add for a new component.

Parameters

entity: Entity
An entity that already has the component type.
component: C
The replacement type value.

Returns

Unit

Unit after the replacement is accepted.

Examples

Replace a component

set updates an already attached component.

Tick 0 · 0.00 s⌘ / Ctrl + EnterThis device
main.kj
Loading the language runtime…
Output 0
No output.
Expected output
2

Rust definition

Rust interpreter builtin dispatch; Type is specialized from the concrete component type.

See also