对象如何在Lua中引用自身? [英] How does an object reference itself in Lua?

查看:66
本文介绍了对象如何在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.

推荐答案

来自

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆