Lua丨#运算符

版权声明:欢迎转载,转载请注明出处 https://blog.csdn.net/weixin_38239050/article/details/82493503
mytab={q,w,e,r}
print(#mytab)

mytab.q=1
mytab.w=2
print(#mytab)

mytab[1]=1
mytab[2]=2
print(#mytab)

--实际输出的是已赋值value的序号
mytab[4]=1
print(#mytab)

--必须有对应的key
mytab[8]=1
print(#mytab)




>lua -e "io.stdout:setvbuf 'no'" "table.lua" 
0
0
2
4
4
>Exit code: 0

猜你喜欢

转载自blog.csdn.net/weixin_38239050/article/details/82493503
今日推荐