小编cht*_*son的帖子

Lua课不起作用

我在Lua中有一个简单的类实现.

test = {}
test.__index = test

function test:new()
    local o = {}
    setmetatable(o, self)
    return o
end

function test:setName(name)
    self.name = name
    print name
end

local name = test:new()
name:setName("hello")
Run Code Online (Sandbox Code Playgroud)

我运行时不断收到此错误:

lua:test.lua:12:'='预计在'name'附近

我不确定这是什么或为什么会发生这种情况,我们将非常感谢任何帮助.

lua metatable lua-table

3
推荐指数
1
解决办法
136
查看次数

标签 统计

lua ×1

lua-table ×1

metatable ×1