Expressions can be used as *input arguments* in blocks.
For example, use the Expression true block to check if an expression evaluate to true.

To write an expression, switch to “expression mode” by tapping the icon next to an *input argument* field.
Tap the to return to “constant mode”.

An expression is any valid unit of code that resolves to a value. Automate has the following expression categories:

*Arithmetic:*evaluates to a number, for example 3.14159. See arithmetic operators.*Text:*evaluates to text, for example, "Hello World" or "234". See special operators.*Logical:*evaluates to true or false. See logical operators.

Automate has the following types of operators:

Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. Any non-numerical operand is first converted to a number.

A binary operator; `1 + 2`

returns 3.

A binary operator; `2 - 1`

returns 1.

A binary operator; `2 * 2`

returns 4.

A binary operator; `10 / 3`

returns 3.333. `10 / 0`

returns Infinity.

A binary operator; `10 // 3`

returns 3. `10 // 0`

returns Infinity.

A binary operator that returns the remainder of dividing the two operands; `12 % 5`

returns 2.

A unary prefix operator that returns the negation of its operand; `-(-5)`

returns 5.

Bitwise operators treat their operands as a set of 32 bits.

A binary operator that returns a one in each bit position for which the corresponding bits of both operands are ones; `0b0101 & 0b0011`

returns 0xb0001.

A binary operator that returns a one in each bit position for which the corresponding bits of either or both operands are ones; `0b0101 | 0b0011`

returns 0b0111.

A binary operator that returns a one in each bit position for which the corresponding bits of either but not both operands are ones; `0b0101 ^ 0b0011`

returns 0x0110.

A unary operator that inverts the bits of its operand; `~0b1`

returns 0xFFFFFFFE.

A binary operator that shifts the bits to the left; `0b10010111 << 1`

returns 0b00101110.

A binary operator that shifts the bits to the right, keeping the sign of a negative number; `0b10010111 >> 1`

returns 0b11001011.

A binary operator that shifts the bits to the right, without keeping the sign of a negative number; `0b10010111 >>> 1`

returns 0b01001011.

A comparison operator compares its operands and returns a logical value based on whether the comparison is true. The operands can be numbers or texts. Texts are compared on case-sensitive lexicographical order.

A binary operator that returns 1 if the operands are equal; `3 = 3`

returns 1.

A binary operator that returns 1 if the operands are not equal; `3 != 3`

returns 0.

A binary operator that returns 1 if the left operand is greater than the right operand; `2 > 2`

returns 0.

A binary operator that returns 1 if the left operand is greater than or equal to the right operand; `2 >= 2`

returns 1.

A binary operator that returns 1 if the left operand is less than the right operand; `2 < 2`

returns 0.

A binary operator that returns 1 if the left operand is less than or equal to the right operand; `2 <= 2`

returns 1.

Automate does not have a value type nor literals for true or false, instead the following are considered false:

- A null value.
- The number zero.
- A NaN (Not-a-number).
- An empty, zero length text.
- An empty array.
- An empty dictionary.

All other values are considered true.

A binary operator that returns left operand if it evaluate to false, otherwise right operand is returned; `2 && 3`

returns 3.

A binary operator that returns left operand if it evaluate to true, otherwise right operand is returned; `2 || 3`

returns 2. `null || 0 || "Hi"`

returns "Hi".

A unary prefix operator that returns 1 if the operand evaluate to true, otherwise 0 is returned; `!3`

returns 0.

An unary prefix operator that returns the operand converted to a number; `+"2"`

returns 2, `+"0xFF"`

returns 255.

An unary prefix operator that returns the operand converted to text; `++2`

returns "2".

A binary operator that returns the two operands concatenated into a text; `"Good"++"bye"`

returns "Goodbye", `2++2`

returns "22".

A ternary operator, operand ? operand : operand; If the first operand evaluate to true the seconds operand is returned,
otherwise the third operand is returned; `2=2 ? "two" : "other"`

returns "two".

An unary prefix operator;

- If the operand is a text, returns the number of characters;
`#"Hi"`

returns 2. - If the operand is an array, returns the number of
*elements*;`#[1,2]`

returns 2. - If the operand is a dictionary, returns the number of
*entries*;`#{"a":1,"b":2}`

returns 2. - Otherwise zero is return returned.

A binary operator, operand[operand];

- If the first operand is a text, returns the Unicode character at the index of the seconds operand;
`"Hi"[1]`

returns 69. - If the first operand is an array, returns the
*element*at the index of the second operand;`["a","b","c"][1]`

returns "b". - If the first operand is a dictionary, returns the value mapped to the key of the second operand;
`{"a":1,"b":2}["b"]`

returns 2. - Otherwise null is returned.

A *constant expression* can only use null
and literals for number, text,
array and dictionary.