xref: /aosp_15_r20/external/bazel-skylib/docs/dicts_doc.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1*bcb5dc79SHONG Yifan<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2*bcb5dc79SHONG Yifan
3*bcb5dc79SHONG YifanSkylib module containing functions that operate on dictionaries.
4*bcb5dc79SHONG Yifan
5*bcb5dc79SHONG Yifan<a id="dicts.add"></a>
6*bcb5dc79SHONG Yifan
7*bcb5dc79SHONG Yifan## dicts.add
8*bcb5dc79SHONG Yifan
9*bcb5dc79SHONG Yifan<pre>
10*bcb5dc79SHONG Yifandicts.add(<a href="#dicts.add-dictionaries">dictionaries</a>, <a href="#dicts.add-kwargs">kwargs</a>)
11*bcb5dc79SHONG Yifan</pre>
12*bcb5dc79SHONG Yifan
13*bcb5dc79SHONG YifanReturns a new `dict` that has all the entries of the given dictionaries.
14*bcb5dc79SHONG Yifan
15*bcb5dc79SHONG YifanIf the same key is present in more than one of the input dictionaries, the
16*bcb5dc79SHONG Yifanlast of them in the argument list overrides any earlier ones.
17*bcb5dc79SHONG Yifan
18*bcb5dc79SHONG YifanThis function is designed to take zero or one arguments as well as multiple
19*bcb5dc79SHONG Yifandictionaries, so that it follows arithmetic identities and callers can avoid
20*bcb5dc79SHONG Yifanspecial cases for their inputs: the sum of zero dictionaries is the empty
21*bcb5dc79SHONG Yifandictionary, and the sum of a single dictionary is a copy of itself.
22*bcb5dc79SHONG Yifan
23*bcb5dc79SHONG Yifan
24*bcb5dc79SHONG Yifan**PARAMETERS**
25*bcb5dc79SHONG Yifan
26*bcb5dc79SHONG Yifan
27*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
28*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
29*bcb5dc79SHONG Yifan| <a id="dicts.add-dictionaries"></a>dictionaries |  Zero or more dictionaries to be added.   |  none |
30*bcb5dc79SHONG Yifan| <a id="dicts.add-kwargs"></a>kwargs |  Additional dictionary passed as keyword args.   |  none |
31*bcb5dc79SHONG Yifan
32*bcb5dc79SHONG Yifan**RETURNS**
33*bcb5dc79SHONG Yifan
34*bcb5dc79SHONG YifanA new `dict` that has all the entries of the given dictionaries.
35*bcb5dc79SHONG Yifan
36*bcb5dc79SHONG Yifan
37*bcb5dc79SHONG Yifan<a id="dicts.omit"></a>
38*bcb5dc79SHONG Yifan
39*bcb5dc79SHONG Yifan## dicts.omit
40*bcb5dc79SHONG Yifan
41*bcb5dc79SHONG Yifan<pre>
42*bcb5dc79SHONG Yifandicts.omit(<a href="#dicts.omit-dictionary">dictionary</a>, <a href="#dicts.omit-keys">keys</a>)
43*bcb5dc79SHONG Yifan</pre>
44*bcb5dc79SHONG Yifan
45*bcb5dc79SHONG YifanReturns a new `dict` that has all the entries of `dictionary` with keys not in `keys`.
46*bcb5dc79SHONG Yifan
47*bcb5dc79SHONG Yifan**PARAMETERS**
48*bcb5dc79SHONG Yifan
49*bcb5dc79SHONG Yifan
50*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
51*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
52*bcb5dc79SHONG Yifan| <a id="dicts.omit-dictionary"></a>dictionary |  A `dict`.   |  none |
53*bcb5dc79SHONG Yifan| <a id="dicts.omit-keys"></a>keys |  A sequence.   |  none |
54*bcb5dc79SHONG Yifan
55*bcb5dc79SHONG Yifan**RETURNS**
56*bcb5dc79SHONG Yifan
57*bcb5dc79SHONG YifanA new `dict` that has all the entries of `dictionary` with keys not in `keys`.
58*bcb5dc79SHONG Yifan
59*bcb5dc79SHONG Yifan
60*bcb5dc79SHONG Yifan<a id="dicts.pick"></a>
61*bcb5dc79SHONG Yifan
62*bcb5dc79SHONG Yifan## dicts.pick
63*bcb5dc79SHONG Yifan
64*bcb5dc79SHONG Yifan<pre>
65*bcb5dc79SHONG Yifandicts.pick(<a href="#dicts.pick-dictionary">dictionary</a>, <a href="#dicts.pick-keys">keys</a>)
66*bcb5dc79SHONG Yifan</pre>
67*bcb5dc79SHONG Yifan
68*bcb5dc79SHONG YifanReturns a new `dict` that has all the entries of `dictionary` with keys in `keys`.
69*bcb5dc79SHONG Yifan
70*bcb5dc79SHONG Yifan**PARAMETERS**
71*bcb5dc79SHONG Yifan
72*bcb5dc79SHONG Yifan
73*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
74*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
75*bcb5dc79SHONG Yifan| <a id="dicts.pick-dictionary"></a>dictionary |  A `dict`.   |  none |
76*bcb5dc79SHONG Yifan| <a id="dicts.pick-keys"></a>keys |  A sequence.   |  none |
77*bcb5dc79SHONG Yifan
78*bcb5dc79SHONG Yifan**RETURNS**
79*bcb5dc79SHONG Yifan
80*bcb5dc79SHONG YifanA new `dict` that has all the entries of `dictionary` with keys in `keys`.
81*bcb5dc79SHONG Yifan
82*bcb5dc79SHONG Yifan
83