Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

record_type

form a record type from a record of types

Synopsis

record_type(r: record) -> type

Description

The record_type function returns the record type with the fields of r in order, where the type of each field is the type value of that field of r, e.g., record_type({x:<int64>,y:<string>}) is <{x:int64,y:string}>.

Each field of r must be a type value. A field whose type value is an option type is an optional field of the record type.

Examples


Form a record type

# spq
values record_type(this)
# input
{x:<int64>,y:<[string]>}
# expected output
<{x:int64,y:[string]}>

Form a record type from the types of a value’s fields with an optional field

# spq
values record_type({a:typeof(a),b:option_type(typeof(b))})
# input
{a:1,b:"x"}
# expected output
<{a:int64,b?:string}>