当前位置 博文首页 > Lua中table里内嵌table的例子

    Lua中table里内嵌table的例子

    作者:admin 时间:2021-02-08 18:01

    废话不多少,看代码:

    复制代码 代码如下:

    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

    js
    下一篇:没有了