valor collection defaults
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Missing list, map, and set fields extracted from value receive usable empty collection handles.
Syntax: <valor-expression> ↦ <genus-type>
Category#
conversion
Related#
Examples#
radix/corpus/reference/conversio/valor-collection-defaults/valor-genus-collections.fab (canonical · conversio)#
Missing list, map, and set fields extracted from value receive usable empty collection handles.
# value ↦ class — seed missing supported collection fields with empty handles
#
# Runtime-owned collection fields require real handles, not null pointers.
# Missing list, map, and set fields extracted from `value` therefore start as
# usable empty collections, while JSON's mandatory-field policy is unchanged.
class EmptyCollections {
mut list<int> items
mut map<string, int> index
mut set<int> keys
}
main {
let value source ← { "unused": 0 } ↦ value
let EmptyCollections extracted ← source ↦ EmptyCollections
print extracted.items.length()
print extracted.index.length()
print extracted.keys.length()
}Expected output:
0
0
0