Creating a vector, appending to it and reading from it
def main(): int {
let values: mutable vector int = [10, 20];
append(values, 12);
return values[0] + values[1] + values[2];
}عرف الرئيسية(): عدد {
دع القيم: متغير متجه عدد = [10, 20];
ألحق(القيم, 12);
أرجع القيم[0] + القيم[1] + القيم[2];
}
Run it
With the interpreter, without compiling:
./build/sultanc run examples/en/collections/vector.snOr compile it to an executable:
./build/sultanc examples/en/collections/vector.sn -o build/example && ./build/example