baml.Map$stream

An insertion-ordered collection of key-value pairs.

Reference version

Signature

class baml.Map$stream<K, V>

An insertion-ordered collection of key-value pairs.

Map<K, V> is spelled map<K, V> in type position. K must be string — the compiler rejects any other key type — so the type parameter exists for uniformity rather than choice; convert other keys with .to_string() first.

Iteration order is the order in which keys were first inserted: keys() and values() follow it, set on an existing key keeps that key's original position, and delete preserves the order of the entries that remain. This is how JavaScript's Map and Python's dict behave — not the arbitrary order of a hash map.

Like arrays, maps are heap objects with reference semantics: a map passed to a function or stored in another container is shared, and every mutating method (set, delete, clear, …) is visible through every reference.

m[key] reads and m[key] = v writes through the map. Reading a key that is not present raises baml.panics.MapKeyNotFound; writing one inserts it at the end. get is the non-panicking read.

When V is nullable, a null returned by get, set or delete is ambiguous between "no such key" and "the key's value is null". has is the way to tell the two apart.

Source:<builtin>/baml/containers.bamlbytes 0–0

Implementations

baml.Concrete for T

Source:<builtin>/baml/core.bamlbytes 747–779