lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


What if the count of values removed exceeds the stack (and thus the vararg) size? For example:

local t = {}
for i = 1, 1e8 do t[i] = i end
local t2 = {table.remove(t, 1, 1e7)}
assert(#t2 == 1e7)
would the return values be truncated? Would an error be thrown (probably preferable)?

On 10.09.22 19:16, Alexander Chernoskutov wrote:
[...] I would like to propose a third argument to `table.remove (list [, pos [, count]])`

`count` - number of elements to remove starting from position `pos` (defaults to 1). All the removed values are returned. [...]