This function will remove the last element in the given array, and return its value. If the array is empty, undefined is returned.
The function works identically to array_shift, but removes and returns the last element instead of the first one.
NOTE To only read the last element in the array without removing it, use array_last.
array_pop(array);
Argument | Type | Description |
---|---|---|
array | Array | The array to remove the last value from. |
var _lastscore = array_pop(score_array);
draw_text(32, 32, "Last Score = " + string(_lastscore));
The above code will pop the last value from the given array, and then draw it along with some text to the screen. The retrieved entry is also removed from the score array.