Next: dict_contains

Prev: dict_add

dict_add_elem

dict_add_elem(dictionary, key, element)
This function returns the result of adding element to the list value key in dictionary. If dictionary has no association with key key, then dict_add_elem() adds an association [key, [element]] to dictionary. If dictionary has an association with key key, and the value part of the association is a list, then dict_add_elem() adds element to the end of that list. If dictionary has an association with key key, but the value part of the association is not a list, then dict_add_elem() throws a ~type error.

Examples:

dict_add_elem(#[["foo", ["bar"]]], "foo", "baz")
     => #[["foo", ["bar", "baz"]]]
dict_add_elem(#[], "foo", "bar")
     => #[["foo", ["bar"]]]