Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove multiple elements from array in Lua

Tags:

lua

lua-table

In Lua, I know there is

table.remove(array, index)

Is there a fast way to remove and return X elements from the array (without just repeated calls to table.remove)?

like image 295
K2xL Avatar asked Oct 20 '22 22:10

K2xL


1 Answers

No; there is no API to remove and return several elements from a table. You can use table.remove, array[index] = nil, or resetting array to an empty table and repopulating (if you have majority elements to remove).

like image 113
Paul Kulchenko Avatar answered Nov 12 '22 17:11

Paul Kulchenko