最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2015年05月28日 11:55:52   投稿:goldensun  
這篇文章主要介紹了Lua中if語句嵌套的使用教程,是Lua入門學(xué)習(xí)中的基礎(chǔ)知識,需要的朋友可以參考下

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

if語句的嵌套語法如下:

復(fù)制代碼 代碼如下:
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語句的方式。
例子:

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

當(dāng)建立和運行上面的代碼,它會產(chǎn)生以下結(jié)果。

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

相關(guān)文章

  • Lua返回一個Closures函數(shù)實例

    Lua返回一個Closures函數(shù)實例

    這篇文章主要介紹了Lua返回一個Closures函數(shù)實例,本文直接給出代碼實例,需要的朋友可以參考下
    2015-04-04
  • 最新評論

    平乐县| 普兰店市| 鄂托克旗| 临夏县| 股票| 道孚县| 永济市| 株洲县| 泸水县| 无锡市| 沈丘县| 安仁县| 瑞丽市| 视频| 正镶白旗| 福清市| 松溪县| 进贤县| 郎溪县| 毕节市| 赤壁市| 天等县| 余干县| 米脂县| 钦州市| 邮箱| 萨迦县| 泸水县| 文昌市| 虎林市| 五家渠市| 和平县| 固安县| 永顺县| 墨脱县| 广饶县| 德钦县| 灵丘县| 莱州市| 古蔺县| 朝阳区|