标签:tags 维表 ring cat string test nat code color
在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
例子二,对多维表的计算:
th> tags={{1,2,3},{3,4,4}}
th> #tags
2
例子三,
th> tags={1,2,3}
[0.0001s]
th> tags[#tags+1]=4
[0.0001s]
th> tags
{
1 : 1
2 : 2
3 : 3
4 : 4
}
标签:tags 维表 ring cat string test nat code color
原文地址:http://www.cnblogs.com/ymjyqsx/p/6146185.html