Skip to main content

Dictionary.insert

insertkeyvalue

Group: Calculations

Documentation

Inserts a key-value mapping into this dictionary, overriding any existing instance of key with the new value. Note that since the return type is also a Dictionary, multiple insert calls can be chained, e.g., dictionary.insert "A" 1 . insert "B" 2. Due to the limitation of the current implementation, inserts with a key that is already contained in the dictionary, or insert on a dictionary instance that is re-used in other computations, have a linear time complexity. For all the other cases, the time complexity of this method is constant.

Arguments

  • key: The key to insert the value for.
  • value: The value to associate with the key.

Examples

Insert the value "seven" into the dictionary for the key 7.

      import Standard.Examples

example_insert = Examples.dictionary.insert 7 "seven"