Array.remove_at
Array.remove_at
Function
Delete and return the element with the specified subscript. Negative subscripts are supported.
Syntax
array.remove_at(index)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| index | Int | No | -1 | The index to delete; negative numbers count backwards from the end. |
Return value
| Type | Description |
|---|---|
| Any/Empty | The deleted element is returned when the subscript is valid, and Empty is returned when it is out of bounds. |
Example
items = ['a', 'b', 'c'] result = items.remove_at(-1) // Output: c print result
Notes
- remove_at will modify the original array.
- If you only need to know whether the deletion was successful, you can continue to use delete(index).