...

/

Types of Evaluation

Types of Evaluation

Let's learn how to evaluate Boolean and string expressions and expressions related to output.

Generator expressions are evaluated to one of two types: Boolean or string. Boolean is represented by 1 (true) and 0 (false). Everything else is just a string.

It’s important to remember that nested expressions passed as conditions in conditional expressions are explicitly required to evaluate Boolean.

There's an explicit logical operator to convert strings to Boolean, but Boolean types can be converted to strings implicitly.

Now that we know the basic syntax, let's take a look at what we can do with it.

Evaluation to Boolean

Continuing with the discussion on conditional expressions, let’s get the whole concept covered right off the bat, so there's no need to return to it later. Three categories of expressions get evaluated to Boolean.

Logical operators

There are four logical operators:

  • $<NOT:arg> negates the Boolean argument.

  • $<AND:arg1,arg2,arg3...> returns 1 if all the arguments are 1.

  • $<OR:arg1,arg2,arg3...> returns 1 if any of the arguments is 1.

  • $<BOOL:string_arg> converts arguments from a string to a Boolean type.

String conversion will evaluate to 1 if none of these conditions are met:

  • The string is empty.

  • The string is a case-insensitive equivalent of 0, FALSE, OFF, N, NO, IGNORE, or NOTFOUND.

  • The string ends in the -NOTFOUND suffix (case-sensitive).

Press + to interact

String comparison

Comparisons will evaluate to 1 if their condition is met and 0 otherwise:

  • $<STREQUAL:arg1,arg2> is a case-sensitive string comparison.

  • $<EQUAL:arg1,arg2> converts a string to a number and compares equality.

  • $<IN_LIST:arg,list> checks whether the arg element is in the list list (case-sensitive).

  • $<VERSION_EQUAL:v1,v2>, $<VERSION_LESS:v1,v2>, $<VERSION_GREATER:v1,v2>, $<VERSION_LESS_EQUAL:v1,v2>, and $<VERSION_GREATER_EQUAL:v1,v2> are component-wise version comparisons.

Variable queries

There are plenty of variables that contain Boolean-typed values. They also will evaluate to 1 if their condition is met and 0 otherwise.

There is one simple query: ...