Skip to main content

Dictionary.from_vector

Dictionary.from_vectorvecerror_on_duplicates

Group: Constants
Aliases: dictionary, lookup table

Documentation

Builds a dictionary from a vector of key-value pairs, with each key-value pair represented as a 2 element vector.

Arguments

  • vec: A vector of key-value pairs (2 element vectors).
  • error_on_duplicates: A flag which specifies if duplicate keys on the input vector should result in an error. By default, set to True, meaning that if two entries in the vector share the same key, an Illegal_Argument error is raised. If set to False, the last entry with a given key will be kept.

Examples

Building a dictionary containing two key-value pairs.

      example_from_vector = Dictionary.from_vector [["A", 1], ["B", 2]]