Array.remove_at
Array.remove_at
功能
删除并返回指定下标的元素,支持负数下标。
语法
array.remove_at(index)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| index | Int | 否 | -1 | 要删除的下标;负数从尾部反向计数。 |
返回值
| 类型 | 说明 |
|---|---|
| Any/Empty | 下标有效时返回被删除元素,越界时返回 Empty。 |
示例
items = ['a', 'b', 'c'] result = items.remove_at(-1) // 输出:c print result
注意事项
- remove_at 会修改原数组。
- 如果只需要知道是否删除成功,可继续使用 delete(index)。