last

返回数组中的最后一项。

输入


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

输出

Tom.

输入


{% 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:


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