'\" t .\" Copyright (c) 2025 Bruce Hill .\" All rights reserved. .\" .TH List.pop 3 2025-11-29 "Tomo man-pages" .SH NAME List.pop \- pop an item from a list .SH LIBRARY Tomo Standard Library .SH SYNOPSIS .nf .BI List.pop\ :\ func(list:\ &[T],\ index:\ Int\ =\ -1\ ->\ T?) .fi .SH DESCRIPTION Removes and returns an item from the list. If the given index is present in the list, the item at that index will be removed and the list will become one element shorter. .SH ARGUMENTS .TS allbox; lb lb lbx lb l l l l. Name Type Description Default list &[T] The list to remove an item from. - index Int The index from which to remove the item. -1 .TE .SH RETURN `none` if the list is empty or the given index does not exist in the list, otherwise the item at the given index. .SH NOTES Since negative indices are counted from the back, the default behavior is to pop the last value. .SH EXAMPLES .EX list := &[10, 20, 30, 40] assert list.pop() == 40 assert list[] == [10, 20, 30] assert list.pop(index=2) == 20 assert list[] == [10, 30] .EE .SH SEE ALSO .BR Tomo-List (3)