Lua - expected "end" (to close the "function" near <eof>), do not see the missing "end"
I get an "end" error message, but I looked through all the code and cannot see 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}
end
end
return t
end
Grid.__call = Grid.new
return Grid
Here is the error:
lua: grid.lua:15: 'end' expected (to close 'function' at line 3) near <eof>
+4
1 answer
Put doin a line function. You have one endthat is relevant functionbut not appropriate (unnecessary) do. (Actually, the compiler considers that it endmatches do, and then complains when it does not see endfor this function.)
The syntax of the function body is approximately
functionname(params opt ) end of block
(For simplicity, see the Lua link .)
A do . , end.
+5