If I have a list (table):
local list = {'foo', 'bar', 'baz', 'qux'}
How do I get the n-th item from the end? (e.g., the last or second to last)
Try list[#list+1-n]
to get the n-th entry from the end, counting from 1 as usual in Lua. So the last item has n=1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With