Skip to content

Commit 8f8def7

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [ExpressionLanguage] Add operators precedence documentation
2 parents 353f47a + c883a11 commit 8f8def7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

reference/formats/expression_language.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,41 @@ Other Operators
397397
* ``?.`` (:ref:`null-safe operator <component-expression-null-safe-operator>`)
398398
* ``??`` (:ref:`null-coalescing operator <component-expression-null-coalescing-operator>`)
399399

400+
Operators Precedence
401+
~~~~~~~~~~~~~~~~~~~~
402+
403+
Operator precedence determines the order in which operations are processed in an
404+
expression. For example, the result of the expression ``1 + 2 * 4`` is ``9``
405+
and not ``12`` because the multiplication operator (``*``) takes precedence over
406+
the addition operator (``+``).
407+
408+
To avoid ambiguities (or to alter the default order of operations) add
409+
parentheses in your expressions (e.g. ``(1 + 2) * 4`` or ``1 + (2 * 4)``.
410+
411+
The following table summarizes the operators and their associativity from the
412+
**highest to the lowest precedence**:
413+
414+
======================================================= =============
415+
Operators associativity
416+
======================================================= =============
417+
``-``, ``+`` (unary operators that add the number sign) none
418+
``**`` right
419+
``*``, ``/``, ``%`` left
420+
``not``, ``!`` none
421+
``~`` left
422+
``+``, ``-`` left
423+
``..`` left
424+
``==``, ``===``, ``!=``, ``!==``, left
425+
``<``, ``>``, ``>=``, ``<=``,
426+
``not in``, ``in``, ``contains``,
427+
``starts with``, ``ends with``, ``matches``
428+
``&`` left
429+
``^`` left
430+
``|`` left
431+
``and``, ``&&`` left
432+
``or``, ``||`` left
433+
======================================================= =============
434+
400435
Built-in Objects and Variables
401436
------------------------------
402437

0 commit comments

Comments
 (0)