Lua中..和#運算符的使用方法
更新時間:2015年05月28日 09:58:14 投稿:goldensun
這篇文章主要介紹了Lua中..和#運算符的使用方法,是Lua入門學習中的基礎知識,需要的朋友可以參考下
通過Lua語言支持其他運算符包括串聯(lián)和長度。
例子
試試下面的例子就明白了在Lua編程語言提供的其他運算符:
復制代碼 代碼如下:
a = "Hello "
b = "World"
b = "World"
print("Concatenation of string a with b is ", a..b )
print("Length of b is ",#b )
print("Length of b is ",#"Test" )
當建立并執(zhí)行上面的程序它會產生以下結果:
復制代碼 代碼如下:
Concatenation of string a with b is Hello World
Length of b is 5
Length of b is 4
Length of b is 5
Length of b is 4