Common programming mistakes
Keep a stored null distinct from a missing key
Looking up either situation can produce null. Use collection.contains when the distinction matters.
use collection
settings = {theme = null}
print(collection.contains(settings, 'theme'))
print(collection.contains(settings, 'volume'))
true
false
The theme key exists with a null value. The volume key is absent.
- Use
value ?? fallbackwhen only null should produce the fallback.oralso treats false as falsey. - Use
collection.containswhen a key may explicitly store null. - Compare
type(value)with descriptors. Text equality can hold for a char and a one-scalar string, even though their types differ. - Use
value?.a?.bfor two optional receiver accesses. A regular access later in the chain still applies normally to its input. - Mark copied graph snapshots as deep with
copy(value, true). Ordinary assignment and shallow copy share nested objects. - Use dot notation to extract a bound method. When calling the stored dictionary function by index, pass the receiver explicitly.
- Match paths to their host platform or specify a supported style where the API allows it. Use
path.joinfor platform-native paths. - Use verified C types, recreate invalidated views, and close each live resource with its own API.