lua-users home
lua-l archive

Re: Lua as Configuration Conditional Statement inside table definition

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


> Enum1 = ENUMERATION {
> {1, "Forward"},
> {2, "Backword"},
> 
> if BIDIERCTIONAL_SUPPORTED then
> {3, "BiDirectional"},
> 
> {4, "None" }
> }
Not pretty but it can be done like this:
Enum1 = ENUMERATION {
 [1]={1, "Forward"},
 [2]={2, "Backword"},
 [(not not BIDIERCTIONAL_SUPPORTED) and 3]={3, "BiDirectional"},
 [4]={4, "None" }
}
which will leave an entry with a false key of BIDIERCTIONAL_SUPPORTED is
nil or false. Just ignore it. :-)
If you can change the syntax, then this is much better
Enum1 = ENUMERATION {
 Forward=1,
 Backword=2,
 BiDirectional= BIDIERCTIONAL_SUPPORTED and 3 or nil
 None=4,
}

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