Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  [ExpressionLanguage] Add operators precedence documentation
  • Loading branch information
javiereguiluz committed May 13, 2024
2 parents 353f47a + c883a11 commit 8f8def7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions reference/formats/expression_language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,41 @@ Other Operators
* ``?.`` (:ref:`null-safe operator <component-expression-null-safe-operator>`)
* ``??`` (:ref:`null-coalescing operator <component-expression-null-coalescing-operator>`)

Operators Precedence
~~~~~~~~~~~~~~~~~~~~

Operator precedence determines the order in which operations are processed in an
expression. For example, the result of the expression ``1 + 2 * 4`` is ``9``
and not ``12`` because the multiplication operator (``*``) takes precedence over
the addition operator (``+``).

To avoid ambiguities (or to alter the default order of operations) add
parentheses in your expressions (e.g. ``(1 + 2) * 4`` or ``1 + (2 * 4)``.

The following table summarizes the operators and their associativity from the
**highest to the lowest precedence**:

======================================================= =============
Operators associativity
======================================================= =============
``-``, ``+`` (unary operators that add the number sign) none
``**`` right
``*``, ``/``, ``%`` left
``not``, ``!`` none
``~`` left
``+``, ``-`` left
``..`` left
``==``, ``===``, ``!=``, ``!==``, left
``<``, ``>``, ``>=``, ``<=``,
``not in``, ``in``, ``contains``,
``starts with``, ``ends with``, ``matches``
``&`` left
``^`` left
``|`` left
``and``, ``&&`` left
``or``, ``||`` left
======================================================= =============

Built-in Objects and Variables
------------------------------

Expand Down

0 comments on commit 8f8def7

Please sign in to comment.