I have data received from another script where the variable has the value "false" or "true". I want to convert this value to true or false in lua datatype. Currently, I can do this long way:
if value == "false" then
value=false
elseif value == "true" then
value=true
end
Is there a simplest way to convert this like converting string to integer tonumber("1")
You can also do this:
stringtoboolean={ ["true"]=true, ["false"]=false }
print(stringtoboolean[s])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With