local a = {};function b() print("Hello World")enda["sell"] = {callFunc =b}a["sell"].callFunc()
使用lua 自帶的 unpack :
解釋:把一直數(shù)組(只有連續(xù)數(shù)字下標的 table)展開成一串返回值,但是對用字符串或別的東西做 key 的 table 無能為力。
function unpackex(tbl, args) local ret = {} for _,v in ipairs(args) do table.insert(ret, tbl[v]) end return unpack(ret)endprint(unpackex({one = {"one", "two", "three"}, two = "T" , three = "TH"},{"one", "two", "three"}))
輸出:>> table: 00ABC2D0TTH
更多建議: