# Array

Operators and functions for working with arrays (**arr** type) are described here. **arr.typename** means that you can specify any type name but in the case of the binary operator this type must be the same in both arrays.

* [bool( arr.typename a ) bool](/stdlib/array.md#bool-arr-typename-a-bool)
* [Join( arr.str a, str sep ) str](/stdlib/array.md#join-arr-str-a-str-sep-str)
* [Reverse( arr.typename a ) arr.typename](/stdlib/array.md#reverse-arr-typename-a-arr-typename)
* [Slice( arr.typename a, int start, int end ) arr.typename](/stdlib/array.md#slice-arr-typename-a-int-start-int-end-arr-typename)
* [Sort( arr.str a ) arr.str](/stdlib/array.md#sort-arr-str-a-arr-str)

## Operators

| Operator                             | Result           | Description                                                                      |
| ------------------------------------ | ---------------- | -------------------------------------------------------------------------------- |
| **\*** arr.typename                  | int              | Returns the number of elements in the array.                                     |
| arr.typename **?**                   | bool             | Calls *bool(arr.typename)*.                                                      |
| arr.typename **=** arr.typename      | arr.typename     | Assignment operator.                                                             |
| arr.typename **&=** arr.typename     | arr.typename     | Creates a clone of the array. The new variable will work with the same data set. |
| arr.typename **+=** arr.typename     | arr.typename     | Adds items from one array to another.                                            |
| arr.str **+=** str                   | arr.str          | Adds a string to an array of strings.                                            |
| arr.int **+=** int                   | arr.int          | Adds an integer number to an array of integer numbers.                           |
| arr.bool **+=** bool                 | arr.bool         | Adds a Boolean value to an array of Boolean values.                              |
| arr.arr.typename **+=** arr.typename | arr.arr.typename | Adds an array to an array of arrays.                                             |
| arr.map.typename **+=** map.typename | arr.map.typename | Adds a map to an array of maps.                                                  |
| arr.typename **\[** int **]**        | typename         | Sets/gets an array value by index.                                               |

## Functions

### bool(arr.typename a) bool

The *bool* function returns *false* if the array is empty, otherwise, it returns *true*.

### Join(arr.str a, str sep) str

The *Join* function joins strings of the array. The separator string *sep* is placed between strings in the resulting string.

### Reverse( arr.typename a ) arr.typename

The *Reverse* function reverses the order of the elements in the array and returns this array.

### Slice( arr.typename a, int start, int end ) arr.typename

The *Slice* function copies some consecutive elements from within an array. *start* is inclusive, while *end* is exclusive. The function returns the created array.

### Sort(arr.str a) arr.str

The *Sort* function sorts an array of strings in increasing order and returns it.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gentee.org/stdlib/array.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
