Removes the last element and returns it. Fails an assert when the array is empty.
Only the count is lowered, so a pointer taken to the element earlier still reads its old value until the slot is reused.
values: [..] int;
array_add(*values, 1, 2, 3);
assert(pop(*values) == 3 && pop(*values) == 2);
assert(values.count == 1);
array_free(values);pop :: (array: *[] $T) -> T
Removes the last element and returns it. Fails an assert when the array is empty.
Only the count is lowered, so a pointer taken to the element earlier still reads its old value until the slot is reused.
Parameters
- array: *[] $T
Returns
- T
values: [..] int;
array_add(*values, 1, 2, 3);
assert(pop(*values) == 3 && pop(*values) == 2);
assert(values.count == 1);
array_free(values);