Class: Array

@include <Array>

Simple Array implementation

Methods

@Array.size

Scope: public

Get the number of elements in the array.

Outputs: The number of elements in the array.

Usage: @Array.size

@Array.push

Scope: public

Add a value to the end of the array.

Usage: @Array.push $value

Parameters

  • value
    • Type: Primitive
    • The value to add to the array.

@Array.pop

Scope: public

Remove and echo the last element of the array.

Returns: 1 if the array is empty, 0 otherwise.

Outputs: The last element of the array.

Usage: @Array.pop

@Array.insert

Scope: public

Insert a value at a specific index in the array.

Returns: 1 if the index is out of bounds, 0 otherwise.

Usage: @Array.insert $index $value

Parameters

  • index
    • Type: Primitive
    • The index at which to insert the value.
  • value
    • Type: Primitive
    • The value to insert into the array.

@Array.remove

Scope: public

Remove the specified index from the array.

Returns: 1 if the index is out of bounds, 0 otherwise.

Usage: @Array.remove $index

Parameters

  • index
    • Type: Primitive
    • The index of the value to remove.

@Array.at

Scope: public

Get the value at a specific index.

Outputs: The value at the specified index.

Usage: @Array.at $index

Parameters

  • index
    • Type: Primitive
    • The index of the value to retrieve.

@Array.front

Scope: public

Echo the first element of the array.

Returns: 1 if the array is empty, 0 otherwise.

Outputs: The first element of the array.

Usage: @Array.front

@Array.back

Scope: public

Echo the last element of the array.

Returns: 1 if the array is empty, 0 otherwise.

Outputs: The last element of the array.

Usage: @Array.back

@Array.all

Scope: public

Echo all elements of the array.

Returns: 1 if the array is empty, 0 otherwise.

Outputs: All elements of the array separated by spaces.

Usage: @Array.all

@Array.empty

Scope: public

Silently returns whether the array is empty.

Returns: 0 if the array is empty, 1 otherwise.

Outputs: nothing

Usage: @Array.empty

@Array.slice

Scope: public

Echo a slice of the array from start to end indices.

Returns: 1 if the start index is greater than the end index or if the array is empty, 0 otherwise.

Outputs: The elements in the specified slice separated by spaces.

Usage: @Array.slice $start $end

Parameters

  • start
    • Type: Primitive
    • The starting index of the slice (inclusive).
  • end
    • Type: Primitive
    • The ending index of the slice (inclusive).

@Array.clear

Scope: public

Clear the array by removing all elements.

Usage: @Array.clear