I have the following function which checks if the given parameter is found as a key in a key-value table. If that is the case it should return true and break out of the loop. If nothing is found then do nothing.
function checkId(id)
for k,v in pairs(info) do
if id == tostring(k) then
return true
break -- break out of loop. mission accomplished.
end
end
end
I get an
'end' expected (to close 'do' at line 192) near 'break'
when I try to run this script. What am I missing?
returnandbreak.returnexits the function. In lua 5.1returnalso has to be the last statement in a block. - Etan Reisner