last
The last filter returns the last element of an array, hash or string.
Array
{{ [1, 2, 3, 4]|last }}
The above will output: 4.
Hash
{{ {'name': 'Sam', 'age': 55}|last }}
String
{{ 'Bob Hope'|last }}
The above will output "e"
Assignment
As with all filters, you can use the last filter when assigning a variable.
{% set name = 'Bob Hope' %}
{% set letter = name|last %}