lua-users home
lua-l archive

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


I ported the Lua persistent tables example:

http://lua-users.org/wiki/PersistentTables

...to Lua 5.0, but I noticed there is a fundamental flaw -- the __newindex metamethod is only called if the current value at the index is nil.

Ie; it only works if you do this:

persistent_table[0] = nil
persistent_table[0] = "new value"

If you miss the first line, and that index already has a value, the new value doesn't get saved... Any ideas?

Steven