local Grid = {}
Grid.__index = Grid
function Grid.new(w, h) do
t = {}
setmetatable(t,Grid)< br /> for i=1,w do
t[i] = {}
for j=1,h do
t[i][j] = {i, j, nil }
end
end
return t
end
Grid.__call = Grid.new
return Grid
This is an error:
lua: grid.lua:15:'end' expected (to close'function' at line 3) near
The syntax of the function body is approximate
function
name(
paramsopt) block end
(This is too simple, please refer to the Lua reference for details.)
No need to do. If it is there, it is not the syntax of the function body Part, and must match the corresponding end.
I received an error saying that the “end” is missing, but I looked at the entire code without seeing it.
local Grid = {}
Grid.__index = Grid
function Grid.new(w, h) do
t = {}
setmetatable(t,Grid)
for i=1,w do
t[i] = {}
for j=1,h do
t[i][j] = {i, j, nil}< br /> end
end
return t
end
Grid.__call = Grid.new
return Grid
This is an error: p>
lua: grid.lua:15:'end' expected (to close'function' at line 3) near
< /p>
Remove the do on the function line. You have a matching function at the end, but no match (unnecessary). (Actually the compiler thinks the end matches do, and then complains when it doesn’t see the end of the function .)
The syntax of the function body is approximate
function
name em>(
paramsopt) block end
(This is Too simple, see the Lua reference for details.)
No need to do. If it is there, it is not part of the syntax of the function body and must match the corresponding end.