push

Function push 

Source
pub fn push(args: &[Value]) -> Result<Value, RuntimeError>
Expand description

添加元素到数组末尾

§功能

在数组末尾添加一个新元素,返回新的数组。原数组不会被修改。

§参数

  • array: Array - 原始数组
  • value: Any - 要添加的元素(任意类型)

§返回值

Array - 包含新元素的新数组

§示例

Set arr [1, 2, 3]
Set newArr Push(arr, 4)     # [1, 2, 3, 4]
Println(arr)                # [1, 2, 3] (原数组不变)