5
我试图将空值传递给函数,但失败。这是我的设置;如何将空变量传递给函数Lua
function gameBonus.new(x, y, kind, howFast) -- constructor
local newgameBonus = {
x = x or 0,
y = y or 0,
kind = kind or "no kind",
howFast = howFast or "no speed"
}
return setmetatable(newgameBonus, gameBonus_mt)
end
我只想传递“kind”并希望构造函数处理其余部分。喜欢;
local dog3 = dog.new("" ,"" , "bonus","")
或者我只想通过“howFast”;
local dog3 = dog.new(, , , "faster")
我都与""
并没有尝试过,给人的错误:
unexpected symbol near ','