std_hashmap is an implementation of the hashmap data type, also known as a dictionary or table.
fetch(std_hashmap);
obj my_hashmap = hashmap();
obj my_hashmap = hashmap_set(my_hashmap, "user", "bob");
obj my_hashmap = hashmap_set(my_hashmap, "age", 23);
obj my_hashmap = hashmap_set(my_hashmap, "birthday", "1/1/25");
obj birthday = hashmap_get(my_hashmap, "birthday");
bark(birthday); # output: 1/1/25
Constructs a new hashmap and returns it.
obj example = hashmap();
bark(example);
Sets the hashmap_obj's pair of key & value and returns a new version .
obj example = hashmap();
obj example = hashmap_set(example, "key", "value");
bark(example);
Returns the hashmap_obj's value of key.
obj example = hashmap();
obj example = hashmap_set(example, "key", "value");
bark(hashmap_get(example, "key")); # output: value
Removes the hashmap_obj's pair of key and returns a new version with the removed pair.
obj example = hashmap();
obj example = hashmap_set(example, "key", "value");
obj removed = hashmap_remove(example, "key"); # empty hashmap because we removed the only key
bark(removed);
Returns a list of the hashmap_obj's keys.
obj example = hashmap();
obj example = hashmap_set(example, "key1", "value");
obj example = hashmap_set(example, "key2", "value");
obj keys = hashmap_keys(example);
bark(keys); # output: [key1, key2]
Returns a list of the hashmap_obj's values.
obj example = hashmap();
obj example = hashmap_set(example, "key1", "value1");
obj example = hashmap_set(example, "key2", "value2");
obj values = hashmap_keys(example);
bark(values); # output: [value1, value2]
Pretty print a hashmap.
obj example = hashmap();
obj example = hashmap_set(example, "key1", "value1");
bark_hashmap(example);
# output:
# {
# key1: value1
# }