萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> Lua中..和#運算符的使用方法

Lua中..和#運算符的使用方法

   這篇文章主要介紹了Lua中..和#運算符的使用方法,是Lua入門學習中的基礎知識,需要的朋友可以參考下

  通過Lua語言支持其他運算符包括串聯和長度。

201552895552401.jpg (624×208)

  例子

  試試下面的例子就明白了在Lua編程語言提供的其他運算符:

  代碼如下:

  a = "Hello "

  b = "World"

  print("Concatenation of string a with b is ", a..b )

  print("Length of b is ",#b )

  print("Length of b is ",#"Test" )

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

   代碼如下:

  Concatenation of string a with b is Hello World

  Length of b is 5

  Length of b is 4

copyright © 萬盛學電腦網 all rights reserved