Lua中的逻辑运算符使用详解(lua与运算)不看后悔

随心笔谈5个月前更新 admin
213 00
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买

文章摘要

这篇文章主要展示了变量赋值和条件判断的逻辑流程。代码中通过赋值`a=5`和`b=20`,首先判断`a`和`b`的条件,打印了“Line 1 - Condition is true”,接着改变`a`和`b`的值为`0`和`10`,再次判断条件并打印了“Line 3 - Condition is true”和“Line 3 - Condition is not true”。最后,还通过`not(a and b)`的条件判断,打印了“Line 4 - Condition is true”和“Line 3 - Condition is not true”。文章通过具体的赋值和条件判断,突出了程序中变量值变化对逻辑判断结果的影响。

a=5

b=20

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

© 版权声明

相关文章