Pop

Verb: pop

Removes the last item from a Stack.

Stack is a type of Collection, which uses the LIFO (last-in first-out) method. The last element inserted is always the first one to be extracted.

Syntax

pop --collection(IStack<Variant>) [--handleerror(Boolean)] (Boolean)=success (Variant)=value

Inputs

Script Designer Required AcceptedTypes Description
--collection Stack Required IStack<Any> Stack that should have its last item removed.
--handleerror Handle Error Optional Boolean When enabled, if an error occurs during the command execution, the current script will not fail and information regarding that error are returned on the Output. If it is not enabled, the script will failed when an error occurs.

Outputs

Script Designer AcceptedTypes Description
success Success Boolean Returns "True" if the item was successfully removed from the stack, or "False" otherwise.
value Item removed Any Item removed from the Stack.

Example

Removes the last inserted item from a "Stack" type collection.

defVar --name collectionNumbers --type Stack --innertype Numeric --value "[11,22,33,44,55,66,77,88,99]"
defVar --name itemRemoved --type Numeric
logMessage --message "Stack before removing last item: ${collectionNumbers};" --type "Info"
pop --collection "${collectionNumbers}" itemRemoved=value
logMessage --message "Stack after removing last item: ${collectionNumbers};" --type "Info"
logMessage --message "Item removed: ${itemRemoved}." --type "Info"
// Return obtained after script execution:
// Stack before removing last item: [99,88,77,66,55,44,33,22,11];
// Stack after removing last item: [88,77,66,55,44,33,22,11];
// Item removed: 99.

See Also

  • Count Items
  • Dequeue
  • Get Item from Stack or Queue
  • Get List Item
  • Remove Items from Collection