Basic module

peek

procedure · 1 overloadSource

The last element of the array, without removing it. Fails an assert when the array is empty.

ExampleOpen in playground ↗
values := int.[3, 6, 9];
assert(peek(values) == 9);
peek_pointer(values).* = 10;
assert(values[2] == 10);
peek :: (array: [] $T) -> T

The last element of the array, without removing it. Fails an assert when the array is empty.

Parameters

array: [] $T

Returns

T
ExampleOpen in playground ↗
values := int.[3, 6, 9];
assert(peek(values) == 9);
peek_pointer(values).* = 10;
assert(values[2] == 10);

See also