last

Filters = last

Returns the last item of an array.

INPUT

OUTPUT

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

Tom

INPUT

OUTPUT

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

tiger

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

Example

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