K2xL
K2xL

Reputation: 10270

Remove multiple elements from array in Lua

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)?

Upvotes: 7

Views: 3820

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26744

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).

Upvotes: 4

Related Questions