[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua tables/keys
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Wed, 12 Mar 2008 09:17:27 -0600
On Wed, Mar 12, 2008 at 9:06 AM, Alexandr Leykin <leykina@gmail.com> wrote:
> a = {a,b,c,d}
This is equivalent to:
a = {[1] = a, [2] = b, [3] = c, [4] = d}
>
> a.a => nil, but key "a" present in table!
> a.f => nil, but key "f" not in table!
You probably want:
a = {["a"] = true, ["b"] = true, ["c"] = true, ["d"] = true}
Then,
a.a => true (present in table)
a.f => nil (not present in table)
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
-Will Durant