Qu

dict

Builtin index · Collections & strings

dict() or dict(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.

CodeInputOutputDescription
dict() or dict(k, v, ...)no inputno outputWith 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
false

from collections-strings