[英]Lua: String to name?
is it possible to convert a string into a name of a table entry? 是否可以将字符串转换为表条目的名称? just like
就像
string = "test"
y = {test = 123}
print y.string
So if string is "test" it would print y.test if there is such a entry 因此,如果字符串是“ test”,那么如果有这样的条目,它将打印y.test
Hope you understand my question! 希望你理解我的问题!
Thanks in advance... 提前致谢...
print(y[string])
Be careful with using names such as string for variables, especially globals. 对于变量,尤其是全局变量,请使用诸如字符串之类的名称。 You've just overwritten the string table.
您刚刚覆盖了字符串表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.