Lua 元表(Metatable)

📝

内容提要

__index 元方法 __newindex 元方法 __tostring 元方法 在 Lua table 中我们可以访问对应的 key 来得到 value 值,但是却无法对两个 table 进行操作。 因此 Lua 提供了元表(Metatable),允许我们改变 table 的行为,每个行为关联了对应的元方法。 例如,使用元表我们可以定义 Lua 如何计算两个 table...

🏷️

标签

➡️

继续阅读