lua call function from a string with function name

后端 未结 5 2004
感动是毒
感动是毒 2020-12-13 05:19

Is it possible in lua to execute a function from a string representing its name?
i.e: I have the string x = \"foo\", is it possible to do x() ?

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 05:52

    Names are not unique, there can be many functions names foo in different namespaces. But _G['foo'] is foo in the global namespace.

提交回复
热议问题