Files
modeling-app/docs/kcl/push.md
Adam Chalmers 50f8131d83 Kwargs: map and reduce (#6480)
Migrate array's `map`, `reduce` and `push` functions to use keyword arguments.
2025-04-25 19:09:03 -05:00

26 KiB

title, excerpt, layout
title excerpt layout
push Append an element to the end of an array. manual

Append an element to the end of an array.

Returns a new array with the element appended.

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

Arguments

Name Type Description Required
array [KclValue] The array which you're adding a new item to. Yes
item KclValue The new item to add to the array Yes

Returns

KclValue - Any KCL value.

Examples

arr = [1, 2, 3]
new_arr = push(arr, item = 4)
assert(
  new_arr[3],
  isEqualTo = 4,
  tolerance = 0.1,
  error = "4 was added to the end of the array",
)

Rendered example of push 0