lua-users home
lua-l archive

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


Second: How do I check if a key exists? (I don't think I can use an
inverted table because I'll end up with duplicate keys, or not?)

You should just be able to check your_table["key"] or alternately your_table.key. If it has no value (hasn't been set yet), it'll return nil.

Lua 5.1.2  Copyright (C) 1994-2007 Lua.org, PUC-Rio
> chars = {}
> chars.a = 5
> if chars.a then print("yes") end
yes
> if chars.b then print("yes") end
> = chars.b
nil