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

nameof

the name of a named type

Synopsis

nameof(val: any) -> string

Description

The nameof function returns the type name of val as a string if val is a named type. Otherwise, it returns an error.

Examples


A named type yields its name and unnamed types values a missing error

# spq
values nameof(this)
# input
type port=int16
80::port
80
# expected output
"port"
error({message:"nameof: not a type",on:80})