国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

Lua中關系運算符的使用教程

2024-07-21 23:04:49
字體:
來源:轉載
供稿:網友

下表列出了所有的Lua語言支持的關系運算符。假設變量A持有10和變量B持有20則:

Lua,運算符

示例

試試下面的例子就明白了所有的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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 镇安县| 会理县| 北京市| 揭西县| 荔波县| 武义县| 西乌珠穆沁旗| 寿光市| 天柱县| 丰台区| 略阳县| 潜江市| 将乐县| 浠水县| 廊坊市| 临桂县| 西华县| 曲阜市| 临湘市| 奎屯市| 全州县| 延长县| 民乐县| 天等县| 海晏县| 平湖市| 旌德县| 彭州市| 曲水县| 始兴县| 宜兴市| 宣化县| 麻江县| 东海县| 庆阳市| 巨野县| 大丰市| 芜湖县| 通江县| 绥宁县| 巨野县|