Dict (dict)

Stores a mapping of strings to other objects. See dictionaries.

You can also iterate over dictionaries with the foreach statement.

(since 0.48.0) Dictionaries can be added (e.g. d1 = d2 + d3 and d1 += d2). Values from the second dictionary overrides values from the first.

Dict methods

dict.get()

returns the value for the key given as first argument if it is present in the dictionary, or the optional fallback value given as the second argument. If a single argument was given and the key was not found, causes a fatal error

Signature

# returns the value for the key given as first
any get(
  str key,          # The key to query
  any [fallback],   # Fallback value that is returned if the key is not in the dict.
)

Arguments

Argument flattening is NOT SUPPORTED by this function.

The method dict.get() accepts the following positional arguments:

Name Type Description Tags
key str

The key to query.

fallback any

Fallback value that is returned if the key is not in the dict.

[optional]


dict.has_key()

Returns true if the dictionary contains the key given as argument, false otherwise.

Signature

# Returns `true` if the dictionary contains the key given as argument, `false` otherwise
bool has_key(
  str key,     # The key to query
)

Arguments

The method dict.has_key() accepts the following positional arguments:

Name Type Description Tags
key str

The key to query.


dict.keys()

Returns an array of keys in the dictionary.

Signature

list[str] keys()


The results of the search are