local a = {};
function b()
	print("Hello World")
end
a["sell"] = {callFunc =b}
a["sell"].callFunc()


技巧2:


    使用lua 自带的 unpack :

    解释:把一直数组(仅仅有连续数字下标的 table)展开成一串返回值。可是对用字符串或别的东西做 key 的 table 无能为力。

function unpackex(tbl, args)
	local ret = {}
	for _,v in ipairs(args) do
		table.insert(ret, tbl[v])
	end
	return unpack(ret)
end

print(unpackex({one = {"one", "two", "three"}, two = "T" , three = "TH"},{"one", "two", "three"}))

    输出:>>  table: 00ABC2D0 T TH

相关文章:

  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2023-03-11
  • 2022-12-23
猜你喜欢
  • 2021-09-26
  • 2022-12-23
  • 2021-06-23
  • 2021-11-07
  • 2021-12-28
  • 2022-03-09
  • 2022-12-23
相关资源
相似解决方案