unpack的使用
t = {"nihao",fg="asd"}
t[10] = 'love'
print(unpack(t)) --nihao
print(t.fg) --asd
print(t[10]) --love

t[2] = 100
t[3] = nil 
t[4] = 200
print(unpack(t)) --nihao 100 nil 200


unpack函数会从table的下标1开始,一直往上递增,直到遇到nil索引为止


首页 我的博客
粤ICP备17103704号