lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've googled and searched the archive to no avail ...

Is there a way to detect duplicate field names in a table?

Suppose I want users to be able to configure an app using lua.  They create a table like:


I want to detect and reject any duplicate keys (eg key1=key2).  By default, Lua appears to ignore all but the last instance of the key.  (I'm guessing that it actually installs val1 at key1 but then replaces val1 with val2.)  That is OK in some cases, but I've got lots of keys and want to detect typos that lead to duplicates.

I've figured out how to iterate over key, value pairs but the duplicates are skipped.

Any way to handle this?


Looking for last minute shopping deals? Find them fast with Yahoo! Search.