title: Are fallback tables a common practice in lua?
body: <p>I have a need to write some Lua code but having come from a C background some of the common practices and programming strategies seem unusual to me. That said I wrote some code that illustrates what I am having trouble with:</p>
  <pre><code>local someFunction(myName)
    local fallbackTable = {name = &quot;&quot;}    
  
    local myTable = getTableOrReturnNil(someArgument) or fallbackTable
    local otherName = myTable[&quot;name&quot;]
    --other code that is irrelevant
  end
  </code></pre>
  <p>My question is specifically regarding the line <code>local myTable = getTableOrReturnNil(someArgument) or fallbackTable</code>. From what I understand this expression will evaluate to <code>fallbackTable</code> if the return value from <code>getTableOrReturnNil()</code> return nil. It may be worth mentioning that I do not have control over the function <code>getTableOrReturnNil()</code>. Is this a common practice or is there a more standard way to do <code>local otherName = myTable[&quot;name&quot;]</code> safely without having to worry about if <code>myTable</code> is nil. I can resort to using a chain of if's but I would rather avoid this if possible.</p>