3 ms·
Which Lua has also, for strings, and it's quite convenient. Doesn't work for tables, though, because you can actually put something at foo[-1], which can be us
by samatman 6y ago
Which Lua has also, for strings, and it's quite convenient.
Doesn't work for tables, though, because you can actually put something at foo[-1], which can be useful.
I find that foo[#foo+1] is more common than foo[#foo] in my code, that is to say I add to an array more often than I access the last slot. Although I typically use the idiomatic table.insert(foo, bar) instead— but that's mostly because it's slightly awkward to add the +1 all the time.