[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntactic sugar for sets
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 27 Mar 2007 09:41:19 -0300
> example = {["foo"], ["bar"], ["baz"]}
>
> as an abbreviation for
>
> example = {["foo"] = true, ["bar"] = true, ["baz"] = true}
This hadn't come up until now, but a common idiom is to let Lua do the work:
function makeset(t)
local s={}
for i,v in ipairs(t) do
s[v]=true
end
return s
end
example = makeset{"foo", "bar", "baz"}
--lhf