首页 > 其他 > 详细

#在lua中的运用

时间:2016-12-08 20:45:01      阅读:192      评论:0      收藏:0      [点我收藏+]

在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
}

 

#在lua中的运用

原文:http://www.cnblogs.com/ymjyqsx/p/6146185.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!