345b6573d73173d136628cfb68f50f4619c0d532
[yaffs-website] / vendor / twig / twig / doc / filters / last.rst
1 ``last``
2 ========
3
4 .. versionadded:: 1.12.2
5     The ``last`` filter was added in Twig 1.12.2.
6
7 The ``last`` filter returns the last "element" of a sequence, a mapping, or
8 a string:
9
10 .. code-block:: jinja
11
12     {{ [1, 2, 3, 4]|last }}
13     {# outputs 4 #}
14
15     {{ { a: 1, b: 2, c: 3, d: 4 }|last }}
16     {# outputs 4 #}
17
18     {{ '1234'|last }}
19     {# outputs 4 #}
20
21 .. note::
22
23     It also works with objects implementing the `Traversable`_ interface.
24
25 .. _`Traversable`: http://php.net/manual/en/class.traversable.php