Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 651 Bytes

nameof.md

File metadata and controls

35 lines (27 loc) · 651 Bytes

Function

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 error("missing").

Examples

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

echo '80(port=int16) 80' | super -z -c 'yield nameof(this)' -

=>

"port"
error("missing")

The missing value can be ignored with quiet:

echo '80(port=int16) 80' | super -z -c 'yield quiet(nameof(this))' -

=>

"port"