Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 Lua 的对象引用中使用变量?例如,a.Value 是一个字符串,a.Value = "b"。我想访问 abcd 或 a.(a.Value).cd 我怎样才能做到这一点?
语法a.b实际上是a["b"]. 要做你想做的事,你会摆脱"b"变量,而是使用变量,如下所示:
a.b
a["b"]
"b"
a[a.Value].c.d