Skip to content

Commit c38868c

Browse files
committed
Add a not about the return value of destructuring
1 parent 8784815 commit c38868c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

doc/templates.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,13 +1111,21 @@ parentheses:
11111111
Destructuring
11121112
-------------
11131113

1114+
.. versionadded:: 3.23
1115+
1116+
Destructuring was added in Twig 3.23.
1117+
11141118
Destructuring allows you to extract values from sequences and assign them to
11151119
variables in a single operation using the ``=`` :ref:`assignment operator
11161120
<templates-assignment-operator>`.
11171121

1118-
.. versionadded:: 3.23
1122+
Like in PHP, destructuring expressions return the right-hand side value, not
1123+
the extracted values:
11191124

1120-
Destructuring was added in Twig 3.23.
1125+
.. code-block:: twig
1126+
1127+
{# returns the full user object, allowing chained access #}
1128+
{{ ({name} = user).email }}
11211129
11221130
Sequence Destructuring
11231131
~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)