code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(43 lines)
1 '\" t
2 .\" Copyright (c) 2025 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Table.get 3 2025-11-29 "Tomo man-pages"
6 .SH NAME
7 Table.get \- get an item from a table
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Table.get\ :\ func(t:\ {K:V},\ key:\ K\ ->\ V?)
13 .fi
14 .SH DESCRIPTION
15 Retrieves the value associated with a key, or returns `none` if the key is not present.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx
23 l l l.
24 Name Type Description
25 t {K:V} The table.
26 key K The key whose associated value is to be retrieved.
27 .TE
28 .SH RETURN
29 The value associated with the key or `none` if the key is not found.
31 .SH NOTES
32 Default values for the table are ignored.
34 .SH EXAMPLES
35 .EX
36 t := {"A": 1, "B": 2}
37 assert t.get("A") == 1
38 assert t.get("????") == none
39 assert t.get("A")! == 1
40 assert t.get("????") or 0 == 0
41 .EE
42 .SH SEE ALSO
43 .BR Tomo-Table (3)