last

Returns the last item of an array.

Input

{{ "Ground control to Major Tom." | split: " " | last }}

Output

Tom.

Input

{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
{{ my_array.last }}

Output


tiger

You can use last with dot notation when you need to use the filter inside a tag:

{% if my_array.last == "tiger" %}
There goes a tiger!
{% endif %}