Array (array)

An array of elements. See arrays.

Returned by

Array objects are returned by the following functions and methods:

Array methods

array.contains()

Returns true if the array contains the object given as argument, false otherwise

Signature

# Returns `true` if the array contains the object
bool contains(
  any item,     # The item to check
)

Arguments

Argument flattening is NOT SUPPORTED by this function.

The method array.contains() accepts the following positional arguments:

Name Type Description Tags
item any

The item to check


array.flatten()

Returns a flattened copy of the array, with all nested arrays removed.

Signature

(since 1.9.0)

array[any] flatten()


array.get()

returns the object at the given index, negative indices count from the back of the array, indexing out of bounds returns the fallback value (since 0.38.0) or, if it is not specified, causes a fatal error

Signature

# returns the object at the given index,
any get(
  int index,        # Index of the array position to query
  any [fallback],   # Fallback value that is returned if the index is out of range
)

Arguments

Argument flattening is NOT SUPPORTED by this function.

The method array.get() accepts the following positional arguments:

Name Type Description Tags
index int

Index of the array position to query. Negative values start at the end of the array

fallback any

Fallback value that is returned if the index is out of range.

[optional]


array.length()

Returns the current size of the array.

Signature

int length()


array.slice()

Return a selection of the elements of the array starting at index start and continuing with step size jumps until stop. Negative indices count from the back of the array. The step size cannot be zero, but may be negative. If it is negative, start and stop default to the end and beginning of the array, respectively. If step is positive, start defaults to 0 and stop defaults to the length of the array. Either both or none of start and stop must be provided to prevent ambiguity.

Signature

(since 1.10.0)

# Return a selection of the elements of the array starting at index `start`
array[any] slice(
  int [start],   # The lower bound of the slice
  int [stop],    # The upper bound of the slice

  # Keyword arguments:
  step : int  # The step size
)

Arguments

The method array.slice() accepts the following positional arguments:

Name Type Description Tags
start int

The lower bound of the slice

[optional]

stop int

The upper bound of the slice

[optional]

Finally, array.slice() accepts the following keyword arguments:

Name Type Description Tags
step int

The step size

default = 1


The results of the search are