Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enumeration (enum in lua) .Want to use enum in lua5.2.4

I have a condition where in my lua script I want to use enum like for SUCCESS I can give 1 and for FAILURE I can give 0 I am using lua version 5.2.4 Can anyone please help me on how to use enum I want to use enum

elseif(cc_config_cmd == "DELETE" and file_found==1)then
            api:executeString("callcenter_config queue unload " .. queue_name)
            stream:write("1")
else
            stream:write("0")

end
like image 435
ayush jain Avatar asked Dec 20 '25 20:12

ayush jain


1 Answers

There are no enums in Lua.

Simply define variables.

SUCCESS = "1"
FAILURE = "0"

stream:write(SUCCESS)

Or put it into a table which would be quite similar to enum style syntax.

Result = {SUCCESS = "1", FAILURE = "0"}
stream:write(Result.SUCCESS)
like image 94
Piglet Avatar answered Dec 24 '25 12:12

Piglet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!