has

has (schema itemName -- hasName)

Inputs

Outputs

Tests whether the dereferenced schema contains at least one item matching the requested known name.

The name must be known, non-NIL Text. This is a known-name presence test, not a selected-item ordinal lookup. Any matching item makes the result TRUE.

Only the schema participates. Current value contents do not participate.

has uses the same name-matching rules as fieldIndex, but it stops at presence and does not return which ordinal matched.

Behavior

Example

{} () {} [
  mixed: { 1 "" def x: 1; y: 2; };

  "-- Dict field names --" printCompilerMessage
  mixed "x" has printStack _:;
  @mixed "x" has printStack _:;

  "-- empty name --" printCompilerMessage
  mixed "" has printStack _:;
  (1 FALSE) "" has printStack _:;
  () "" has printStack _:;

  "-- missing name --" printCompilerMessage
  mixed "z" has printStack _:;
  (1 FALSE) "x" has printStack _:;
] "main" exportFunction

Expected Output During Compilation

-- Dict field names --
TRUE
TRUE
-- empty name --
TRUE
TRUE
FALSE
-- missing name --
FALSE
FALSE

See also