# Logical Operators

Boolean operators & (and), | (or), and ! (not) operate as expected. Boolean assignment (and queries) coerce non-boolean attributes to either to or false.

number | zero is false and any non-zero is true.
string | "" and "false" are false, other values are true
set | empty sets are false, all others are true
date | "never" is false, all others are true
color | "black" (or RGB(0,0,0) or "#000" or "‹000000") is false, others are true

#### Logical equality tests

Use == to equality and != to test inequality. The older form of using a single equals sign (=) for an equality test is now deprecated.

A direct reference to an attribute of any data type can be be used as Boolean test for a (non-zero value):

> `$MyString` is the same as testing `$MyString!=""`

> `!$MyString` is the same as testing `$MyString==""`

> `$MyNumber` is the same as testing `$MyNumber!=0`

> `!$MyNumber` is the same as testing `$MyNumber==0`

> `$MyDate` is the same as testing `$MyDate!=date("never")`

> `!$MyDate` is the same as testing `$MyDate==date("never")`

Action, File, List, Set and URL data types conform to the String type test above as their data is just a particular form of string.

#### Logical Group Operators

Logical group operators examine a group of notes and determine whether every note in the group meets a criterion, or if any note does.

every(group,expression)

any(group,expression)

The designator group describes the notes to be examined. group may be any group designator {child,descendant,sibling,ancestor,all}. In addition, group may take a single argument that designates a particular group other than this; for example

> `collect(children(/agents/books),$Name)`

The expression may be any valid expression, but is most often a reference to an attribute.

> `any(children,$overdue)`

> `every(children,$status="important")`