Remove multiple elements from array in Lua
Asked Answered
R

1

7

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

Ratiocinate answered 17/11, 2014 at 3:45 Comment(0)
A
4

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

Alyssaalyssum answered 17/11, 2014 at 5:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.