[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Shorten long boolean IF conditions?
- From: Pierre Chapuis <catwell@...>
- Date: Fri, 19 Aug 2011 09:42:27 +0200
On Fri, 19 Aug 2011 09:09:28 +0200, Daniel Hertrich wrote:
if strCustomPropertyValue in ("inbox", "today", "thisweek",
"thismonth", "thisyear", "later", "someday", "archive",
"otherpersons") then
...
end
Is something like this possible in Lua? I have not found a way yet.
for _,x in ipairs{"inbox", "today", "thisweek", "thismonth",
"thisyear", "later", "someday", "archive", "otherpersons"} do
if strCustomPropertyValue == x then
...
end
end
Or you could convert it to a Lua-style Set (see
http://www.lua.org/pil/13.1.html) first:
if (Set.new{"inbox", "today", "thisweek", "thismonth",
"thisyear", "later", "someday", "archive",
"otherpersons"})[strCustomPropertyValue] then
...
end
--
Pierre 'catwell' Chapuis