我不明白
的逻辑 aBoolValue = false
ans = aBoolValue and 'yes' or 'no'
print (ans)
'and'和'或'运算符到底有什么作用?
答案 0 :(得分:4)
答案 1 :(得分:0)
考虑以下代码:
local example1 = true and "yes" or "no"
local example2 = false and "yes" or "no"
print(example1, example2) --> yes no
如果布尔值为true,则将返回after之后的值。如果布尔值为false,则返回或将返回值。可以这样想:
local example1 = if (true) then "yes" else "no"
--obviously this code won't work, but it shows how ternary operations work