Search code examples
lualua-table

Meaning of this table syntax


table = table or {}

What does this do, why do you put your table in your table? I‘m thankfull for all kind of help.


Solution

  • This code assigns an empty table {}to the variable table if it is nil, otherwise table keeps its original value. Basically it is a shortcut for

    if table == nil then table = {} end