Is there any way to declare and reserve a space for a big array without using table.insert?
Something like in Python:
a = [0]*10000
or in C:
malloc(10000*sizeof(int))
Lua tables are dynamic: they grow as needed. There is no need (and no way) to declare a large array. Just create it with a={} and fill it as needed.
If you must create a large array, just fill it with some value:
a={}
for i=1,10000 do
a[i]=true
end
In any case, this is not really a job for table.insert.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With