lua-users home
lua-l archive

Re: Lua Basics: tables as lists?

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


> Lua:
> mylist = {"a", "b", "c"};
> a = "a"
> if mylist[a] ~= nil then
> print "a is in the list"
> end
Did you try it? In Lua the table
 {"a", "b", "c"}
is the same as
 {[1] = "a", [2] = "b", [3] = "c"}
which only has numeric keys, so there is no key "a".
--
Wim

AltStyle によって変換されたページ (->オリジナル) /