Collections
Lists
A dynamically sized array of elements of Type T.
Declaration
list[num] numbers = [1, 2, 3];
list[char] chars = ['a', 'b', 'c'];
Access
Access is strictly checked. .at(index) returns a rox_result[T].
rox_result[num] res = numbers.at(0);
if (isOk(res)) {
num val = getValue(res);
}
Methods
.size() -> num: Returns the number of elements..append(item) -> none: Adds an item to the end..pop() -> none: Removes the last item..at(index) -> rox_result[T]: Safely retrieves an item.
Dictionaries
A key-value map of elements of Type K and V.
Declaration
dictionary[num, string] d;
d.set(1, "one");
dictionary[string, num] scores;
scores.set("player1", 100);
Verification
Access returns a rox_result[V] which must be checked.
rox_result[string] res = d.get(1);
if (isOk(res)) {
string val = getValue(res);
}
Methods
.set(key, value) -> none: Inserts or updates a key-value pair..remove(key) -> none: Removes the key and its value..has(key) -> bool: Checks if a key exists..size() -> num: Returns the number of elements..get(key) -> rox_result[V]: Safely retrieves a value..getKeys() -> list[K]: Returns a list of all keys.