DavidSzczesniak
12/4/2017 - 4:48 PM

Push, pop, shift and unshift

Some of the common array functions

# == Push, Pop, Shift and Unshift ==

# Define initial array content
@basket = ("Apple", "Banana", "Carrot");
# Add an element to the end of the array with PUSH
push(@basket, "Orange");
# Add an element to the beginning of the array with UNSHIFT
unshift(@basket, "Avocado");
# Remove an element from the end of the array with POP 
pop(@basket);
# Remove an element from the beginning of the array with SHIFT
shift(@basket);