我想设置表成员的索引,但仍然命名它们。那可能吗?
local table = {
["cat"] = {
["fish"] = { stuff = "bla1", stuff2 = "bla" },
["mouse"] = { stuff = "bla2", stuff2 = "bla" },
["bird"] = { stuff = "bla3", stuff2 = "bla" },
},
["dog"] = {
["fish"] = { stuff = "bla1", stuff2 = "bla" },
["mouse"] = { stuff = "bla2", stuff2 = "bla" },
["bird"] = { stuff = "bla3", stuff2 = "bla" },
},
}
table["cat"][1]
是fish
,但我想要的table["cat"][0]
是fish
,我怎样才能做到这一点?
编辑:
我仍然希望能够fish
使用table["cat"]["fish"]
.
编辑2:
当我尝试反之亦然时怎么办?http://repl.it/MCu 我做错了什么?