dict
Builtin index · Collections & strings
dict()ordict(k, v, ...)
Input: no input · Output: no output
What it is
With no arguments: an empty store. Otherwise k/v are parallel Vec/List of keys and values (Str or number keys).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
dict() or dict(k, v, ...) | no input | no output | With no arguments: an empty store. Otherwise k/v are parallel Vec/List of keys and values (Str or number keys). |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
d = dict(["a", "b"], [1, 2])
d = set(d, "c", 3)
print(get(d, "b")) # 2
print(keys(d)) # ("a", "b", "c")
print(values(d)) # (1, 2, 3)
print(items(d)) # (("a", 1), ("b", 2), ("c", 3))
print(has_key(d, "c")) # true
print(has_key(d, "z")) # false
output
2
("a", "b", "c")
(1, 2, 3)
(("a", 1), ("b", 2), ("c", 3))
true
falsefrom collections-strings