You still have to iterate to get key.
You can use pairs
for any keys and ipairs
for sequential integer keys starting from 1.
pairs
uses next
function which returns next key in the table but it can't be used to find specific key without iterating it.
To find a key for the value "A stupid one" use this:
for k,v in pairs(t) do
if v == "A stupid one" then
print("Key is:", k)
break
end
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…