I cannot seem that Lua is evaluating booleans.
Here is a trivial snippet designed to demonstrate the problem:
function foo() return true end function gentest() return 41 end function print_hello() print ('Hello') end idx = 0 while (idx < 10) do if foo() then if (not gentest() == 42) then print_hello() end end idx = idx +1 end
When this script is run, I expect to see "Hello" printed on the console, but nothing is printed. Can someone explain this?
Inside the while loop, you should use notoutside the brackets:
not
while (idx < 10) do if foo() then if not (gentest() == 42) then print_hello() end end idx = idx +1 end
(gentest() == 42)will return false, then not falsewill return true.
(gentest() == 42)
not false
(not gentest() == 42)matches with ( (not gentest()) == 42). Since not gentest()returns not 41== false, you will receive false == 42and finally return false.
(not gentest() == 42)
( (not gentest()) == 42)
not gentest()
not 41
false
false == 42
Try it not (gentest() == 42)..
not (gentest() == 42)
, , not , ==,
==
if ((not 41) == 42) then
... , , - ( ) 42.
"" , . , - " a" , , , , "a", " a" , , , , 'a' . , "" , , "if a not = 42", , .
Source: https://habr.com/ru/post/1792259/More articles:Requires: Cuckoo Hashing in C # - c #Grails: custom validator based on previous field value - grailsSQL to generate a range of valid values between two known integers - sqlWhen to use a web service and when not to use a web service? - architectureWPF flickers during animation in Viewport3D - animationDynamically create pdf file with background image - phpEquivalent to #define in tcl? - c-preprocessorASP.NET access to external servers inside the panel - c #Mapper question in C # .NET - activerecordCmake "set" does not work with the same variable after calling "find_path" - windowsAll Articles