types.Array.pop
Method on every
arrayRemoves and returns the last element.
Return value
The removed element.
Errors
Throws empty array when the array has no elements.
Notes
top reads the same element without removing it.
Example
let a = [1, 2, 3];
println("a.pop() =", a.pop()); // removes and returns the last element
println("a.len() =", a.len());
try { [].pop() } catch (e) { println("[].pop() throws:", e); }Output:
a.pop() = 3
a.len() = 2
[].pop() throws: empty arraySee also
top | Returns the last element without removing it. |
append | Adds one or more values to the end of the array. |
| array | class index |