开发者

how do i iterate the tables parameters which is present under the main table?

开发者 https://www.devze.com 2023-03-06 05:49 出处:网络
In lua ,im calling a function which returns a table variable that contains many parameter internally..but when i get that value i couldnt access the paramter which is present in the table. I can see t

In lua ,im calling a function which returns a table variable that contains many parameter internally..but when i get that value i couldnt access the paramter which is present in the table. I can see the tables parameter in the original function in the form of

[[table:0x0989]] { [[table:0x23456]] str = "hello" width = 180 }, [[table:0x23489]] { str1 = "world" }

it shows like this.but when it returns once i can able to get the top address of table like [[table:0x0989]]..when i tried acessing the tables which is present inside the main table.it is showi开发者_开发技巧ng a nil value...how do i call that ?? can anyone help me??


If I'm reading it correctly you're doing this:

function my_function ()
    --do something
    return ({a=1, b=2, c=3})
end

From that you should be able to do this:

my_table = my_function()

then

print(my_table.a) --=> 1
print(my_table.b) --=> 2
print(my_table.c) --=> 3
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号