首页 > Web开发 > 详细

Lua中table里内嵌table的例子

时间:2016-01-31 19:05:23      阅读:348      评论:0      收藏:0      [点我收藏+]

废话不多少,看代码:

复制代码 代码如下:

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

Lua中table里内嵌table的例子

原文:http://www.jb51.net/article/64610.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!