LUA 5.1和Python类

你知道在 Python 中怎样创建一个类:

class className(object):
    def __init__(self):
        # INIT called first in a class

我的问题是,在 Lua 中你怎样实现这种功能呢? Lua 中是否有类?如果有,那么像 Python 中的 __init__() 这样的函数在 Lua 中是什么? 我刚开始学习 Lua 5.1,我注意到我还没有遇到过类。 在 Lua 中,是不是使用表的方式来创建类,例如:

function getName(name) return name end
local className -- class
className['getName'] = getName
className.getName('name')
点赞