Skip to content
Ivan Pidhurskyi edited this page Nov 26, 2025 · 1 revision

Dictionary Type

type dict(K, V)

Hash table / associative array mapping keys to values.

Constructors:

  • dict() - Empty dictionary
  • dict(eq_fn, hash_fn, initial_size) - Custom dictionary

Operations:

  • dict[key] - Access value by key
  • set dict[key] = value - Assign value to key (also: identifier!(osl#set)(dict, key, value))
  • get(dict, key, default) - Lookup key with default value if not found
  • contains(dict, key) - Check if key exists in dictionary
  • remove(dict, key) - Remove key-value pair from dictionary
  • clear(dict) - Remove all entries from dictionary
  • length(dict) - Get number of entries in dictionary
  • empty(dict) - Check if dictionary is empty
  • keys(dict) - Get a list of dictionary keys
  • vals(dict) - Get a list of dictionary values
  • dict1 + dict2 - Merge two dictionaries
  • iter(dict) - Create iterator over key and value pairs
  • foreach(dict, fn(key, value)) - Execute function for each key-value pair
  • map(dict, fn(key, value)) - Transform dictionary into a list using a function

Clone this wiki locally