Why does if then return break end not work in Lua inside for loop -
i have following function checks if given parameter found key in key-value table. if case should return true , break out of loop. if nothing found nothing.
function checkid(id) k,v in pairs(info) if id == tostring(k) return true break -- break out of loop. mission accomplished. end end end i
'end' expected (to close 'do' @ line 192) near 'break'
when try run script. missing?
logically can't return and break that.
return exits function (so don't need break).
that specific error because in lua return has last statement in block.
Comments
Post a Comment