is

Table of Contents

Function

is — test a value’s type

Synopsis

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

Description

The is function returns true if the argument val is of type t. If val is omitted, it defaults to this. The is function is shorthand for typeof(val)==t.

Examples

Test simple types:

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

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

yield is(<{s:string}>)
{s:"hello"}
Loading...

If you test a named type with it’s underlying type, the types are different, but if you use the type name or typeunder function, there is a match:

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

To test the underlying type, just use ==:

yield typeunder(this)==<{s:string}>
{s:"hello"}(=foo)
Loading...
Next: is_error

SuperDB