Skip to content

Latest commit

 

History

History
60 lines (50 loc) · 1.06 KB

kind.md

File metadata and controls

60 lines (50 loc) · 1.06 KB

Function

kind — return a value's type category

Synopsis

kind(val: any) -> string

Description

The kind function returns the category of the type of v as a string, e.g., "record", "set", "primitive", etc. If v is a type value, then the type category of the referenced type is returned.

Example:

A primitive value's kind is "primitive":

echo '1 "a" 10.0.0.1' | super -z -c 'yield kind(this)' -

=>

"primitive"
"primitive"
"primitive"

A complex value's kind is it's complex type category. Try it on these empty values of various complex types:

echo '{} [] |[]| |{}| 1((int64,string))' | super -z -c 'yield kind(this)' -

=>

"record"
"array"
"set"
"map"
"union"

A Zed error has kind "error":

echo null | super -z -c 'yield kind(1/0)' -

=>

"error"

A Zed type's kind is the kind of the type:

echo '<{s:string}>' | super -z -c 'yield kind(this)' -

=>

"record"