lua – 如何在初始化期间自引用表
发布时间:2020-12-15 00:26:43 所属栏目:大数据 来源:网络整理
导读:有没有更短的方法来做到这一点: local thisismytable = { non = sequitur}thisismytable.whatismytable = thisismytable 任何帮助,将不胜感激. 我不想重新创建预先存在的功能. 解决方法 没有. 如果你能够站在这两个表达式之间的区别这个主题:whatismytable
有没有更短的方法来做到这一点:
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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |