This repository has been archived on 2025-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
rhaj/rhai_engine/rhaibook/ref/indexing.md
2025-04-03 09:18:05 +02:00

803 B

Indexing


Some data types take an index that is not an integer.
For example, [object map](object-maps.md) indices are [strings](strings-chars.md).

Some data types, such as arrays, can be indexed via a Rust-like syntax:

object [ index ]

object [ index ] = value ;

Usually, a runtime error is raised if the index value is out of bounds or does not exist for the object's data type.

Elvis Notation

The Elvis notation is similar except that it returns () if the object itself is ().

// returns () if object is ()
object ?[ index ]

// no action if object is ()
object ?[ index ] = value ;