kcl

push

Append an element to the end of an array.

Returns a new array with the element appended.

push(
  array: [KclValue],
  elem: KclValue,
): KclValue

Arguments

NameTypeDescriptionRequired
array[KclValue]Yes
elemKclValueAny KCL value.Yes

Returns

KclValue - Any KCL value.

Examples

arr = [1, 2, 3]
new_arr = push(arr, 4)
assertEqual(new_arr[3], 4, 0.00001, "4 was added to the end of the array")

Rendered example of push 0