Types of Evaluation

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).

Get hands-on with 1400+ tech skills courses.