Skip to content
Konjure / spatial intelligence

add

← Builtin reference

Adds a record component to an existing entity.

Signature

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

C means a concrete type value. Adding a component that the entity already owns, or addressing a missing entity, rejects the current transaction.

Parameters

entity: Entity
An existing entity identity.
component: C
A type value whose type is not already attached.

Returns

Unit

Unit after the component update is accepted.

Examples

Add a component

A new Sphere component becomes queryable on the entity.

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

Rust definition

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

See also