I have a multidimensional array: array[1][7]
How would I remove only the second dimension (the 7)?
table.remove() does not work on multidimensional arrays from my understanding
I have a multidimensional array: array[1][7]
How would I remove only the second dimension (the 7)?
table.remove() does not work on multidimensional arrays from my understanding
did you use remove function this way?
table.remove(array[1], 7)
Just tested it, this doesn’t work unfortunately
code:
data[1] = {}
data[1][7] = {}
print(data)
table.remove(data[1],7)
print(data)
Both prints are the same
seems to work if you will state that inbetween space is nil
if you dont need the benefit of table.remove function which is removing an item at an index and then shifting rest of the items on the right to the left by one index you could just set that value on that index to nil
array[1][7] = nil
or if you need it you can do it manually
local function RemoveItem(Table, Index)
Table[Index] = nil
for i, Value in pairs(Table) do
if i > Index then
Table[i - 1] = Value
Table[i] = nil
end
end
end
this works perfectly
data[1][7] = nil
I didn’t know setting it to nil removes the index, thanks
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.