title: How to get number of entries in a Lua table?
body: <p>Sounds like a "let me google it for you" question, but somehow I can't find an answer. The Lua <code>#</code> operator only counts entries with integer keys, and so does <code>table.getn</code>:</p>
  
  <pre><code>tbl = {}
  tbl["test"] = 47
  tbl[1] = 48
  print(#tbl, table.getn(tbl))   -- prints "1     1"
  
  count = 0
  for _ in pairs(tbl) do count = count + 1 end
  print(count)            -- prints "2"
  </code></pre>
  
  <p>How do I get the number of <em>all</em> entries without counting them?</p>