ethos/tests/array.ethlang
sfja 54ee879b45
All checks were successful
Check / Explore-Gitea-Actions (push) Successful in 8s
progress on arrays and slices
2026-03-17 00:06:43 +01:00

26 lines
476 B
Rust

fn main()
{
let array: [int; 3] = [1, 2, 3];
let elem: int = array[0];
// expect: 1
print_int(elem);
let ptr_to_array: *[int; 3] = &array;
// expect: 2
print_int(ptr_to_array.*[1]);
let slice: *[int] = &array[..];
// // e xpect: 2
// print_int(slice.*[2]);
// let slice_mut: *mut [int] = &mut array[1..3];
// slice_mut.*[0] = 4;
// // e xpect: 4
// print_int(array[1]);
}
// vim: syntax=rust commentstring=//\ %s