下表列出了所有的Lua語言支持的邏輯運算符。假設變量A持有true,而變量B持有false:
示例
試試下面的例子就明白了所有的Lua編程語言提供的邏輯運算符:
if ( a and b )
then
print("Line 1 - Condition is true" )
end
if ( a or b )
then
print("Line 2 - Condition is true" )
end
--lets change the value ofa and b
a = 0
b = 10
if ( a and b )
then
print("Line 3 - Condition is true" )
else
print("Line 3 - Condition is not true" )
end
if ( not( a and b) )
then
print("Line 4 - Condition is true" )
else
print("Line 3 - Condition is not true" )
end
當建立并執行上面的程序它會產生以下結果:
新聞熱點
疑難解答