Skip to main content
Version: 0.4.12

Operators

Operators are functions with specialized syntax for ease of use. They come in two forms: unary and binary.

Unary Operators

There are only two unary operators in MistQL

OperatorParameter TypeReturn TypeDescription
!AnyBooleanfalse if the argument is truthy, true otherwise
-NumberNumberReturns the negative of the number

Binary Operators

Binary operators make up the vast majority of MistQL's operators.

OperatorParameter TypesReturn TypeDescription
+number or string or arraynumber or string or arrayAdds two numbers, concatanates two strings, or concatanates two arrays, depending on argument type
-numbernumberSubtracts one number from another
*numbernumberMultiplies 2 numbers
/numbernumberDivides one number by another
%numbernumberComputes a mod b
<number, string, boolean or nullbooleanLess Than
>number, string, boolean or nullbooleanGreater Than
<=number, string, boolean or nullbooleanLess Than or Equal
>=number, string, boolean or nullbooleanGreater Than or Equal
==anybooleanWhether two values are equivalent
!=anybooleanWhether two values are not equivalent
=~string or regexbooleanWhether the left hand value matches the right hand pattern. Alias for match.
&&ttReturns the first if the first is falsy, the second otherwiseotherwise.
||ttReturns the first if the first is truthy, the second otherwise. NOTE: The backslashes aren't necessary. I just can't figure out how to format it properly for Docusaurus.

Operator precedence and associativity

Below are in order from highest to lowest, where all operators on the same level are equal precedence.

OperatorAssociativity
.ltr
unary !, unary -rtl
*, /, %ltr
+, -ltr
<, >, <=, >=ltr
==, !=, =~ltr
&&ltr
||ltr
[function application]ltr
|ltr