THP Logo THP
class

Array[A]

A dynamic list of values of the same type.

An array is a data structure that can hold a collection of elements, all of the same type. Arrays are commonly used to store lists of items and provide various methods to manipulate and access these items.

Common operations

  • Op 1
  • Op 2: ref

Example

print("Hello world!")

Type Parameters

A

The type of the elements in the array.

Functions

fun push(mut self, element: A) -> Usize

Adds an element to the end & returns the new length of the array.

fun pop(mut self) -> A

Removes the last element & returns that element.

fun map(self, callback: (A) -> B) -> Array[B]

Creates a new array with the results of calling a function on every element.

fun is_empty(self) -> Bool

Returns true if the array has no elements.

fun clear(mut self)

Removes all elements from the array.

See Also