INPUT /  OUTPUT /  LANGUAGE






true tag

Category: ephemeral logic tag

Produces the true value, or tests for the true value against zero or more given values.

Sample usage

<true> — expresses the value true

<true 1,0,null,{true},true> — tests the values in the primary field and produces the resulting values: false,false,false,false,true. Although three of the values in the primary field would logically evaluate to true, only the last one is the value true itself.

Fields

Primary field

Category: vector field

Optional. The primary field may contain one or more values to test against.

Behavior

The true tag, when used without any field values, may be used to express the literal value true anywhere it is required.

When at least one primary field value is specified, the tag functions in a different way: it tests values for being exactly the value true

This is different from using the eq tag to check if a value is 'equals' true. Many values such as nonzero integers or non-empty strings of text are evaluated as being equal to true even if the values have different types, but the true tag tests for an exact match to the value true itself.

Example

In the following code, both the eq and true tags are used to compare a vector containing various values.

<v:vector 52.5,null,false,true>
- values are: <join delim={,} v></n>
- eq tag produces:
    <join delim={,} 
        <i:for 1 limit=v.# do=
            <eq true, <v.@ i>>
        >
    ></n>
- true tag produces: <join delim={,} | true v></n>

Although the false tag accepts multiple values and can produce a list of results, the eq tag only produces a single result of comparison, hence a for tag is used to test against each value. In both cases, the join tag is used to separate the values with commas so the list of values doesn't run together when pushed into the console.

The following appears in the console. The eq tag is used to test if each of the values logically and arithmetically equates to true even if they are different types, but the true tag imposes a stronger condition, requiring them to be of the same type.

- values are: 52.5,,false,true
- true tag produces: false,false,false,true
- eq tag produces: true,false,false,true

In this case the expression <eq true, 52.5> evaluates to true, but the expression <true 52.5> evaluates to false, hence the difference in output.