slige/examples/generic_array.slg

20 lines
467 B
Plaintext
Raw Normal View History

2024-12-26 02:56:59 +00:00
//
2024-12-26 01:38:32 +00:00
fn array_new<T>() -> [T] #[builtin(ArrayNew)] {}
fn array_push<T>(array: [T], value: T) #[builtin(ArrayPush)] {}
fn array_length<T>(array: [T]) -> int #[builtin(ArrayLength)] {}
fn array_at<T>(array: [T], index: int) -> string #[builtin(ArrayAt)] {}
fn main() {
let strings = array_new::<string>();
2024-12-26 02:56:59 +00:00
array_push(strings, "hello");
array_push(strings, "world");
2024-12-26 01:38:32 +00:00
let ints = array_new::<int>();
2024-12-26 02:56:59 +00:00
array_push(ints, 1);
array_push(ints, 2);
2024-12-26 01:38:32 +00:00
}