Lua 中的对象如何引用自身? [英] How does an object reference itself in Lua?
本文介绍了Lua 中的对象如何引用自身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C#有this
,VB有ME
.Lua 的等价物是什么?
C# has this
and VB has ME
. What is the Lua equivalent?
我正在尝试在 Roblox 中引用脚本类的父级.
I am trying to reference the parent of the script class in Roblox.
推荐答案
来自 Lua 文档第 2.5.9 节,自引用通常是self
:
From the Lua documentation section 2.5.9, the self reference is usually self
:
冒号语法用于定义方法,即函数有一个隐含的额外参数 self
.因此,声明
The colon syntax is used for defining methods, that is, functions that have an implicit extra parameter
self
. Thus, the statement
function t.a.b.c:f (params) body end
是
t.a.b.c.f = function (self, params) body end
这篇关于Lua 中的对象如何引用自身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文