Get array name inside array

3

Well, what I want is this: get the name of an array inside another array, just the name. EX:

local a = 
{
["oi"] = {sim=1, nao=2},
["tchau"] = {sim=2, nao=1}
}
local falas = {}
table.insert(falas, a)

- I would add the "hi" and "bye" values to the table talks. This is the intention, but I do not know how.

    
asked by anonymous 21.08.2014 / 11:29

1 answer

5

Would that be what you want?

local n = 0
for k,v in pairs(a) do
    n = n+1
    falas[n] = k
end

Example on ideone . Source: this question in SOen .

    
21.08.2014 / 11:54