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 ','