Skip to content

Array

1 min read

No import is needed.

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

length

Builtin array length (resolved as ArrayLen before instance dispatch).

public get length(): int

this

Element at index. Panics if index is out of range.

public fun this[index: int]: T

iterator

Enumerator for treating an array as a Collection.

public fun iterator(): Iterator<T>

contains

Returns whether the collection contains the requested key or value.

public fun contains(borrow value: T): bool

index_of

Returns the first matching index, or None when no match exists.

public fun index_of(borrow value: T): Option<int>

slice

Returns a new array copied from start (inclusive) to end (exclusive). Panics unless 0 <= start <= end <= length.

public fun slice(start: int, end: int): T[]

reverse

Reverses the elements in place.

public fun reverse(): void

concat

Returns a new array containing this array followed by other.

public fun concat(borrow other: T[]): T[]