mirror of
https://github.com/erg-lang/erg.git
synced 2025-07-16 01:25:24 +00:00
21 lines
491 B
Python
21 lines
491 B
Python
immut_dict = {"Alice": 1, "Bob": 2, "Charlie": 3}
|
|
assert immut_dict["Alice"] == 1
|
|
_ = immut_dict["Bob"]
|
|
_ = immut_dict.get("Charlie")
|
|
_ = immut_dict.get("Charlie", 4)
|
|
|
|
for! immut_dict.keys(), k =>
|
|
print! k
|
|
for! immut_dict.values(), v =>
|
|
print! v
|
|
for! immut_dict.items(), ((k, v),) =>
|
|
print! k, v
|
|
|
|
_ = immut_dict.copy()
|
|
|
|
mut_dict = !{ "a": 1 }
|
|
mut_dict.update! [("a", 2)], (a, b) -> a + b
|
|
assert mut_dict == {"a": 3}
|
|
mut_dict.insert! "b", 4
|
|
i = mut_dict.remove! "a"
|
|
assert i == 3
|