If statement Lua中的链接逻辑操作
在Lua中,这是最有效的方法吗?谢谢大家!If statement Lua中的链接逻辑操作,if-statement,lua,logical-operators,If Statement,Lua,Logical Operators,在Lua中,这是最有效的方法吗?谢谢大家! if X >= 0 and Y >= 0 then if X1 <= 960 and Y1 <= 720 then someCode() else end else end 如果X>=0且Y>=0,则 如果X1避免嵌套的if语句是一个好主意,我会尝试一个if检查。 最好的确定方法是分析函数,看看哪些函数运行得更快 -- Be paranoid and use lots of parenthesi
if X >= 0 and Y >= 0 then
if X1 <= 960 and Y1 <= 720 then
someCode()
else end
else end
如果X>=0且Y>=0,则
如果X1避免嵌套的if
语句是一个好主意,我会尝试一个if
检查。
最好的确定方法是分析函数,看看哪些函数运行得更快
-- Be paranoid and use lots of parenthesis:
if ( ( (X >= 0) and (Y >= 0) ) and ( (X1 <= 960) and (Y1 <= 720) ) ) then
someCode()
end
——多疑并使用大量括号:
如果((X>=0)和(Y>=0))和((X1=0))
local condition2=((X1您还可以使用运算符使其稍微短一点:
if ((X >= 0 && Y >= 0) && (X1 <= 960 && Y1 <= 920)) then
someCode()
end
if((X>=0&&Y>=0)&(X1)通常,判断一种方法是否真的比另一种方法快的唯一方法是分析两种方法,并查看哪一种方法在常见情况下获胜。我希望您在else end
块中确实有些东西。相关问题:
if ((X >= 0 && Y >= 0) && (X1 <= 960 && Y1 <= 920)) then
someCode()
end