主页 > 知识库 > Lua中关系运算符的使用教程

Lua中关系运算符的使用教程

热门标签:海口智能语音电销机器人好用吗 昆明电话外呼系统好么 杞县地图标注app 外呼系统一天耗费多少流量 艾比利外呼系统 陕西便宜电销机器人软件 免费门店地图标注注册入驻 电话机器人每天搜索多少次 衡水外呼线路解决

下表列出了所有的Lua语言支持的关系运算符。假设变量A持有10和变量B持有20则:

示例

试试下面的例子就明白了所有的Lua编程语言提供的关系运算符:

复制代码 代码如下:
a = 21
b = 10

if( a == b )
then
   print("Line 1 - a is equal to b" )
else
   print("Line 1 - a is not equal to b" )
end

if( a ~= b )
then
   print("Line 2 - a is not equal to b" )
else
   print("Line 2 - a is equal to b" )
end

if ( a b )
then
   print("Line 3 - a is less than b" )
else
   print("Line 3 - a is not less than b" )
end

if ( a > b )
then
   print("Line 4 - a is greater than b" )
else
   print("Line 5 - a is not greater than b" )
end

-- Lets change value of a and b
a = 5
b = 20
if ( a = b )
then
   print("Line 5 - a is either less than or equal to  b" )
end

if ( b >= a )
then
   print("Line 6 - b is either greater than  or equal to b" )
end

当建立并执行上面的程序它会产生以下结果:

复制代码 代码如下:
Line 1 - a is not equal to b
Line 2 - a is not equal to b
Line 3 - a is not less than b
Line 4 - a is greater than b
Line 5 - a is either less than or equal to  b
Line 6 - b is either greater than  or equal to b

您可能感兴趣的文章:
  • Lua中..和#运算符的使用方法
  • Lua中的逻辑运算符使用详解
  • Lua中算术运算符的使用示例
  • Lua中的运算符简明总结
  • Lua学习笔记之运算符和表达式
  • Lua基础之运算符的使用示例

标签:泰安 宿迁 营口 南京 西宁 临沧 海口 昌都

巨人网络通讯声明:本文标题《Lua中关系运算符的使用教程》,本文关键词  Lua,中,关系,运算符,的,使用,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《Lua中关系运算符的使用教程》相关的同类信息!
  • 本页收集关于Lua中关系运算符的使用教程的相关信息资讯供网民参考!
  • 推荐文章