我似乎无法理解Lua评估布尔值的方式。Lua脚本中的奇怪逻辑?
这里是一个平凡的片段意在说明问题:
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
当运行此脚本,我希望看到“你好”印在控制台上 - 但是,没有打印。任何人都可以解释吗?
`〜=`有什么问题? – delnan 2011-02-15 16:28:55