Skip to main content

Data Structures

Ra supports basic data structures like arrays and dictionaries.

Arrays​

Arrays are ordered collections of elements:

let arr = [1, 2, 3, 4];
puts(arr[0]); # Access the first element

push(arr, 5); # Add an element
puts(arr); # Print the array
puts(len(arr)); # Print the length of the array

Dictionaries​

Dictionaries store key-value pairs:

let person = {"name": "Alice", "age": 30};
puts(person["name"]); # Access value by key