【发布时间】:2018-10-29 01:28:32
【问题描述】:
我想将我的构造函数存储在 map 中,以便创建对象,即在 foreach 中为不同的定义类型
类似的东西
ObjByType = { "integer" = IntegerObj, "float" = FloatObj }
x = ObjByType["integer"]( arg1, arg2, arg3 )
【问题讨论】:
标签: arrays dictionary constructor lua
我想将我的构造函数存储在 map 中,以便创建对象,即在 foreach 中为不同的定义类型
类似的东西
ObjByType = { "integer" = IntegerObj, "float" = FloatObj }
x = ObjByType["integer"]( arg1, arg2, arg3 )
【问题讨论】:
标签: arrays dictionary constructor lua
使用这个语法:
ObjByType = { integer = IntegerObj, float = FloatObj }
如果字段不是简单的单词,则为这个:
ObjByType = { ["integer"] = IntegerObj, ["float"] = FloatObj }
【讨论】: