1. Is there any difference between using the below example from the book:

    for key,value in pairs(tbl) do

        tbl[key] = nil

    end

    or using tbl = {} ?

    Is there any difference between using the below example from the book:

    for key,value in pairs(tbl) do

        tbl[key] = nil

    end

    or using tbl = {} ?

    I now realise the above for loop could include extra features for selective removal.

    wish I could edit/delete posts. :(

    Besides the additonal control with the for loop, the second method isn't actually clearing the table. It's simply creating a brand new empty table and discarding the original (the {} brackets are technically the "create table" operators of the Lua language). Depending on how often you do something like this, you can significantly impact performance by overworking the garbage collection system. It also depends on how many entries are in the table and how much data is in each entry. Iterating through each one in the for loop may end up having a larger impact than discarding the table and letting the GC do its thing.

    Appendix C: Best Practices has some further discussions of these problems.

    Thanks Cog, I wasn't aware of that.