API Reference
Classes
Array
Immutable Array.
Methods
Name | Description |
---|---|
| Get the value at the given index. |
| Merge arr to the end of this array. |
| Checks if this array includes searchElement. |
| Create a mutable shallow copy of this array. |
| Returns the index of the first occurrence of searchElement found. |
| Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string. |
| Returns the index of the last occurrence of searchElement found. |
| Returns a shallow copy of a portion of the array. |
| Get the value at the given index, returning nil if the index is out of bounds. |
at
at(index: num): <T>
Get the value at the given index.
index
Required
- Type: num
index of the value to get.
concat
concat(arr: Array): Array
Merge arr to the end of this array.
arr
Required
- Type: Array
array to merge.
contains
contains(searchElement: <T>): bool
Checks if this array includes searchElement.
searchElement
Required
- Type: <T>
to search for.
copyMut
copyMut(): MutArray
Create a mutable shallow copy of this array.
indexOf
indexOf(searchElement: <T>): num
Returns the index of the first occurrence of searchElement found.
searchElement
Required
- Type: <T>
to search for.
join
join(separator?: str): str
Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string.
If the array has only one item, then that item will be returned without using the separator.
separator
Optional
- Type: str
lastIndexOf
lastIndexOf(searchElement: <T>): num
Returns the index of the last occurrence of searchElement found.
searchElement
Required
- Type: <T>
to search for.
slice
slice(start?: num, end?: num): Array
Returns a shallow copy of a portion of the array.
start
Optional
- Type: num
the beginning index of the slice, inclusive.
end
Optional
- Type: num
the ending index of the slice, exclusive.
tryAt
tryAt(index: num): <T>?
Get the value at the given index, returning nil if the index is out of bounds.
index
Required
- Type: num
index of the value to get.
Properties
Name | Type | Description |
---|---|---|
| num | The length of the array. |
length
Required
length: num;
- Type: num
The length of the array.
MutArray
Mutable Array.
Methods
Name | Description |
---|---|
| Get the value at the given index. |
| Removes all elements. |
| Merge arr to the end of this array. |
| Checks if this array includes searchElement. |
| Create an immutable shallow copy of this array. |
| Returns the index of the first occurrence of searchElement found. |
| Inserts a new value at the given index of an array. |
| Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string. |
| Returns the index of the last occurrence of searchElement found. |
| Remove value from end of array. |
| Removes value from the given index of an array. |
| Add values to end of array. |
| Removes first occurrence of a given value in an array. |
| Sets a new value at the given index of an array. |
| Returns a shallow copy of a portion of the array. |
at
at(index: num): <T>
Get the value at the given index.
index
Required
- Type: num
index of the value to get.
clear
clear(): void
Removes all elements.
concat
concat(arr: MutArray): MutArray
Merge arr to the end of this array.
arr
Required
- Type: MutArray
array to merge.
contains
contains(searchElement: <T>): bool
Checks if this array includes searchElement.
searchElement
Required
- Type: <T>
to search for.
copy
copy(): Array
Create an immutable shallow copy of this array.
indexOf
indexOf(searchElement: <T>): num
Returns the index of the first occurrence of searchElement found.
searchElement
Required
- Type: <T>
to search for.
insert
insert(index: num, value: <T>): void
Inserts a new value at the given index of an array.
index
Required
- Type: num
the index to insert the value at.
value
Required
- Type: <T>
the value to insert at the given index.
join
join(separator?: str): str
Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string.
If the array has only one item, then that item will be returned without using the separator.
separator
Optional
- Type: str
lastIndexOf
lastIndexOf(searchElement: <T>): num
Returns the index of the last occurrence of searchElement found.
searchElement
Required
- Type: <T>
to search for.
pop
pop(): <T>
Remove value from end of array.
popAt
popAt(index: num): <T>
Removes value from the given index of an array.
index
Required
- Type: num
the index to remove the value at.
push
push(...values: Array<<T>>): void
Add values to end of array.
values
Required
- Type: <T>
values to add.
removeFirst
removeFirst(value: <T>): bool
Removes first occurrence of a given value in an array.
value
Required
- Type: <T>
the value to remove.
set
set(index: num, value: <T>): void
Sets a new value at the given index of an array.
index
Required
- Type: num
the index to set the value at.
value
Required
- Type: <T>
the value to set at the given index.
slice
slice(start?: num, end?: num): MutArray
Returns a shallow copy of a portion of the array.
start
Optional
- Type: num
the beginning index of the slice, inclusive.
end
Optional
- Type: num
the ending index of the slice, exclusive.
Properties
Name | Type | Description |
---|---|---|
| num | The length of the array. |
length
Required
length: num;
- Type: num
The length of the array.