has
Table of Contents
Function
has — test existence of values
Synopsis
has(val: any [, ... val: any]) -> bool
Description
The has function returns false if any of its arguments are error("missing")
and otherwise returns true.
has(e)
is a shortcut for !missing(e)
.
This function is most often used to test the existence of certain fields in an
expected record, e.g., has(a,b)
is true when this
is a record and has
the fields a
and b
, provided their values are not error("missing")
.
It’s also useful in shaping when applying conditional logic based on the presence of certain fields:
switch (
case has(a) => ...
case has(b) => ...
default => ...
)
Examples
yield {yes:has(foo),no:has(bar)}
{foo:10}
Loading...