An ordered owned collection whose elements share one language type.
Signature
List[T]List[T] stores Rust Vec<Value> data. The compiler retains T and the runtime checks elements at typed boundaries. An empty literal needs a contextual element type, such as let values: List[f64] = [];.
Indexing starts at zero and rejects out-of-range indices. Assignment copies a list value; .append(value) returns a new list. .get(index) returns Opt[T], while indexing returns Res[T, DataError]. Collection length and nested values remain subject to the embedding host's Limits.
Methods
Examples
Append without changing the original
append returns a new list. Change the appended value and compare both lists.
main.kj
Loading…Drag to orbit · select to inspect
0 entities
Scene controls
Results
Loading the language runtime…
Output 0
No output.
State
Compile source to inspect its values.
TraceNo execution yet
- Executed source spans appear here.
Expected output
2 2 4 6
Rust definition
Value::List(Vec<Value>); static T and runtime validation enforce homogeneous elements.
View Rust documentation →Support: runtime