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

首頁 > 開發 > 綜合 > 正文

Lua中的邏輯運算符使用詳解

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

下表列出了所有的Lua語言支持的邏輯運算符。假設變量A持有true,而變量B持有false:

Lua,運算符

 示例

試試下面的例子就明白了所有的Lua編程語言提供的邏輯運算符:

 

復制代碼 代碼如下:
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

 

當建立并執行上面的程序它會產生以下結果:

 

復制代碼 代碼如下:
Line 1 - Condition is true
Line 2 - Condition is true
Line 3 - Condition is true
Line 3 - Condition is not true

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 外汇| 紫云| 孝感市| 哈巴河县| 渝北区| 宝丰县| 襄樊市| SHOW| 西城区| 睢宁县| 县级市| 临高县| 甘孜| 石景山区| 磐石市| 灌云县| 沛县| 达州市| 高唐县| 望奎县| 涞源县| 东乡县| 凌海市| 扶余县| 南靖县| 镇宁| 广宗县| 惠水县| 新泰市| 秀山| 伊通| 河间市| 汶上县| 泰来县| 瓮安县| 滁州市| 石柱| 东丽区| 河曲县| 江油市| 定边县|