Is there a way to define a table and assign values to it at the same time?(with for loop)

Something like this

local test = {for i=0,4 do i}
test --> {0,1,2,3,4}

I know in python you can do it, its called list comprehension, but I wasn’t able to find anything regarding how to do it in Lua

local test = {}
for i = 0,4 do
test[i+1] = i
end

No you cannot do it at same time

http://lua-users.org/wiki/ListComprehensions