[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to get the field names for a table
- From: Jean-Claude Wippler <jcw@...>
- Date: Tue, 6 Mar 2001 16:22:44 -0800
Honglei Tu <honglei@synovial.com> wrote:
>Another one:
>If I have a Lua table which is
>color["red" = 1 "green" =5 "blue" =6].
>I wonder how to get the field names and put them
>in a set. I want to get ["red" "green" "blue"].
>I will write a Lua function to get them.
>But is there any way to do that ?
There are no sets in Lua, is the following what you want?
color={red=1,green=5,blue=6}
s={}
for k,v in color do tinsert(s,k) end
print(s[1],s[2],s[3])
-jcw