a question for you please
Is it possible to set a boolean value to a default value if it is not set (nil)?
I am trying the ternary lua way but it does not work for me
https://wiki.gideros.rocks/index.php/Examples#TERNARY_OPERATOR_https:.2F.2Fwww.lua.org.2Fpil.2F3.3.html-- tests
local thover = false -- test
local hover = thover and false or true -- I want to set boolean default = true
print("TEST", hover) -- it always prints TRUE :-/ |
I can achieve what I want using this but it is a hack
local thover = nil -- test
local hover2 = thover or 0
if hover2 == 0 then hover2 = false else hover2 = true end
print("TEST", hover2) |
How do you handle this please?
Comments
Likes: MoKaLux