Files
modeling-app/docs/kcl-std/functions/std-array-push.md
Nick Cameron a049768f1c Move some more functions to be declared in KCL (#6856)
* Move the leg functions to KCL

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Move array functions to KCL

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Move clone to KCL

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Add a function type

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-05-13 08:29:38 +12:00

26 KiB

title, subtitle, excerpt, layout
title subtitle excerpt layout
push Function in std::array Append an element to the end of an array. manual

Append an element to the end of an array.

push(
  @array: [any],
  item: any,
): [any; 1+]

Returns a new array with the element appended.

Arguments

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

Returns

[any; 1+]

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