123456789101112131415161718192021222324252627282930313233343536373839404142434445 | '\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH List.insert 3 2026-03-08 "Tomo man-pages"
.SH NAME
List.insert \- add an item to a list
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.insert\ :\ func(list:\ @[T],\ item:\ T,\ at:\ Int\ =\ 0\ ->\ Void)
.fi
.SH DESCRIPTION
Inserts an element at a specified position in the list.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
list @[T] The mutable reference to the list. -
item T The item to be inserted. -
at Int The index at which to insert the item. 0
.TE
.SH RETURN
Nothing.
.SH NOTES
Since indices are 1-indexed and negative indices mean "starting from the back", an index of `0` means "after the last item".
.SH EXAMPLES
.EX
list := &[10, 20]
list.insert(30)
assert list == [10, 20, 30]
list.insert(999, at=2)
assert list == [10, 999, 20, 30]
.EE
.SH SEE ALSO
.BR Tomo-List (3)
|