Most efficient way to determine if a Lua table is empty (contains no entries)?
Your code is efficient but wrong. (Consider {[false]=0}.) The correct code is if next(myTable) == nil then — myTable is empty end For maximum efficiency you’ll want to bind next to a local variable, e.g., … local next = next … … if next(…) … (When next is local, the code finds primitive function next … Read more