How to remove a lua table entry by its key?

No, setting the key’s value to nil is the accepted way of removing an item in the hashmap portion of a table. What you’re doing is standard. However, I’d recommend not overriding table.remove() – for the array portion of a table, the default table.remove() functionality includes renumbering the indices, which your override would not do. If you do want to add your function to the table function set, then I’d probably name it something like table.removekey() or some such.

Leave a Comment