Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement Lua中的链接逻辑操作_If Statement_Lua_Logical Operators - Fatal编程技术网

If statement 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

在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 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