lua 中table 内嵌table

废话不多少,看代码:

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

你可能感兴趣的:(C/C++,lua学习)