slige/examples/generic_array.slg

20 lines
467 B
Plaintext

//
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>();
array_push(strings, "hello");
array_push(strings, "world");
let ints = array_new::<int>();
array_push(ints, 1);
array_push(ints, 2);
}