Files
modeling-app/docs/kcl/pop.md

26 KiB

title, excerpt, layout
title excerpt layout
pop Remove the last element from an array. manual

Remove the last element from an array.

Returns a new array with the last element removed.

pop(array: [KclValue]) -> KclValue

Arguments

Name Type Description Required
array [KclValue] The array to pop from. Must not be empty. Yes

Returns

KclValue - Any KCL value.

Examples

arr = [1, 2, 3, 4]
new_arr = pop(arr)
assertEqual(new_arr[0], 1, 0.00001, "1 is the first element of the array")
assertEqual(new_arr[1], 2, 0.00001, "2 is the second element of the array")
assertEqual(new_arr[2], 3, 0.00001, "3 is the third element of the array")

Rendered example of pop 0