主頁 > 知識庫 > Lua中if語句嵌套的使用教程

Lua中if語句嵌套的使用教程

熱門標簽:百度地圖標注早餐區(qū)域 地圖標注大廈 冀州市地圖標注 漳州智云呼電話機器人 怎么去除地圖標注 個人怎么在地圖標注需要的店鋪 清朝地圖標注哈爾濱 武漢外呼防封系統(tǒng)多少錢 新岸線智能電銷機器人

 在Lua編程內嵌if-else語句,這意味著可以使用一個 if 或 else if 在另一個語句if或else if 語句中。
語法

if語句的嵌套語法如下:

復制代碼 代碼如下:
if( boolean_expression 1)
then
   --[ Executes when the boolean expression 1 is true --]
   if(boolean_expression 2)
   then
      --[ Executes when the boolean expression 2 is true --]
   end
end

您可以嵌套else if...else 以類似if語句的方式。
例子:

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

當建立和運行上面的代碼,它會產生以下結果。

復制代碼 代碼如下:
Value of a is 100 and b is 200
Exact value of a is : 100
Exact value of b is : 200

您可能感興趣的文章:
  • JQuery自適應IFrame高度(支持嵌套 兼容IE,ff,safafi,chrome)
  • js實現網頁防止被iframe框架嵌套及幾種location.href的區(qū)別
  • js中用window.open()打開多個窗口的name問題
  • javascript window.open打開新窗口后無法再次打開該窗口問題的解決方法
  • window.open()詳解及瀏覽器兼容性問題示例探討
  • js中window.open打開一個新的頁面
  • 講解Python中if語句的嵌套用法
  • 詳解Java編程中if...else語句的嵌套寫法
  • Window.Open打開窗體和if嵌套代碼

標簽:濰坊 臺灣 德宏 宣城 天門 儋州 天門 金昌

巨人網絡通訊聲明:本文標題《Lua中if語句嵌套的使用教程》,本文關鍵詞  Lua,中,語句,嵌套,的,使用,;如發(fā)現本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Lua中if語句嵌套的使用教程》相關的同類信息!
  • 本頁收集關于Lua中if語句嵌套的使用教程的相關信息資訊供網民參考!
  • 推薦文章