lua – 如何在初始化期间自引用表

有没有更短的方法来做到这一点:
local thisismytable = {
    non = sequitur
}
thisismytable.whatismytable = thisismytable

任何帮助,将不胜感激.
我不想重新创建预先存在的功能.

解决方法

没有.

如果你能够站在这两个表达式之间的区别这个主题:whatismytable()而不是thisismytable.whatismytable,你可以这样做:

local thisismytable = {
    non = sequitur,whatismytable = function (self) return self end
}

测试:

print(thisismytable)
print(thisismytable:whatismytable())

更多用法

print(thisismytable:whatismytable().non)

相关文章

1.github代码实践源代码是lua脚本语言,下载th之后运行thmai...
此文为搬运帖,原帖地址https://www.cnblogs.com/zwywilliam/...
Rime输入法通过定义lua文件,可以实现获取当前时间日期的功能...
localfunctiongenerate_action(params)localscale_action=cc...
2022年1月11日13:57:45 官方:https://opm.openresty.org/官...
在Lua中的table(表),就像c#中的HashMap(哈希表),key和...