ArrayPop()

Removes the last element of an array.

In case the array is empty an exception is thrown, unless the second argument "defaultValue" is provided, in that case that value is returned.

ArrayPop( array=array, defaultValue=any );

Returns: any

Argument Description
array
array, required

The array whose last element is to be removed.

defaultValue
any, optional

this value is returned in case the array is empty

Examples

numbers = [ 1, 2, 3, 4 ];
Dump( ArrayPop( numbers ) ); // Outputs 4
moreNumbers = [ 5, 6, 7, 8 ];
Dump( ArrayPop( moreNumbers, 4 ) ); // Outputs 8

See also