content/flux/v0/stdlib/dict/insert.md
dict.insert() inserts a key-value pair into a dictionary and returns a new,
updated dictionary.
If the key already exists in the dictionary, the function overwrites the existing value.
(dict: [A:B], key: A, value: B) => [A:B] where A: Comparable
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
({{< req >}}) Dictionary to update.
({{< req >}}) Key to insert into the dictionary. Must be the same type as the existing keys in the dictionary.
({{< req >}}) Value to insert into the dictionary. Must be the same type as the existing values in the dictionary.
import "dict"
d = [1: "foo", 2: "bar"]
dict.insert(dict: d, key: 3, value: "baz")// Returns [1: "foo", 2: "bar", 3: "baz"]
import "dict"
d = [1: "foo", 2: "bar"]
dict.insert(dict: d, key: 2, value: "baz")// Returns [1: "foo", 2: "baz"]