Lua中table里内嵌table的例子
- 作者: 小人123242549
- 来源: 51数据库
- 2021-07-09
废话不多少,看代码:
复制代码 代码如下:
local temp_insert_table_data = {
x = "test3",
y = "test4",
z = "test5" ,
}
local temp_insert_table = {
x = 1,
y = 2,
z = 3,
{ a = -1, a1 = 1},
{ b = -2, b1 = 2},
{ c = -3, c1 = 3},
temp_insert_table_data_ = temp_insert_table_data,
}
temp_insert_table.temp_insert_table_data_ = temp_insert_table_data
print(temp_insert_table.y)
print(temp_insert_table[1].a)
print(temp_insert_table.temp_insert_table_data_.x)
可以直接通过table_name去访问成员数据!
输出结果:
复制代码 代码如下:
2
-1
test3
推荐阅读
