Lua中if语句嵌套的使用教程(if语句的嵌套)速看

随心笔谈2年前发布 admin
182 0 0

文章摘要

本文介绍了变量赋值和条件判断的基本语法。首先定义局部变量a和b,并分别赋值为100和200。接着检查a是否等于100,若条件成立,再检查b是否等于200。如果两个条件均满足,打印“a和b的值均为100和200”。最后无论条件是否满足,都会打印a和b的值。文章重点强调了变量赋值和条件判断的逻辑关系,展示了如何通过简单的代码实现数值验证功能。尽管代码简洁,但逻辑清晰,便于理解和扩展。

–[ local variable definition –]

a=100;

b=200;

–[ check the boolean condition –]

if( a==100 )

then

   –[ if condition is true then check the following –]

   if( b==200 )

   then

      –[ if condition is true then print the following –]

      print(“Value of a is 100 and b is 200” );

   end

end

print(“Exact value of a is :”, a );

print(“Exact value of b is :”, b );

© 版权声明

相关文章