is

Function

is — test a value’s type

Synopsis

is(val: any, t: type) -> bool

Description

The is function returns true if the argument val is of type t. The is function is shorthand for typeof(val)==t.

Examples

Test simple types:

values {yes:is(this, <float64>),no:is(this, <int64>)}
1.
Loading...

Test for a given input’s record type or “shape”:

values is(this, <{s:string}>)
{s:"hello"}
Loading...

If you test a named type with its underlying type, the types are different, but if you use the type name or typeof and under functions, there is a match:

values is(this, <{s:string}>)
{s:"hello"}::=foo
Loading...
values is(this, <foo>)
{s:"hello"}::=foo
Loading...

To test the underlying type, just use ==:

values under(typeof(this))==<{s:string}>
{s:"hello"}::=foo
Loading...

SuperDB