Push
Verb: push
Adds a new item to the last position of a Stack.
Stack is a type of Collection, which are enumerable data structures that can be accessed using indexes and keys.
Syntax
push --collection(Stack<Variant>) --value(Variant)
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--collection | Stack | Required | Stack<Any> | Stack to which an item should be added at the last position. |
--value | Item added | Required | Any | Item that should be added to the Stack. |
Example
Adds the value "100" to the last position of a Stack.
defVar --name numbersStack --type Stack --innertype Numeric --value "[10,20,30,40,50,60,70,80,90]"
logMessage --message "Stack before stacking a new item: ${numbersStack};" --type "Info"
push --collection "${numbersStack}" --value 100
logMessage --message "Stack after stacking a new item: ${numbersStack};" --type "Info"
// The result obtained after the operation is:
// Stack before stacking a new item: [90,80,70,60,50,40,30,20,10];
// Stack after stacking a new item: [100,90,80,70,60,50,40,30,20,10];
Remarks
The item inserted into Item added must be of the same type as the stack's items.