a={51,31,4,22,23,45,23,43,54,22,11,34}
colors={"white","white","white","white","white","white","white","white","white","white","white","white","white","white","white","white","white"}
function try(f, catch_f)
local status, exception = pcall(f)
if not status then
catch_f(exception)
end
end
function refreshColors(yellowEndIndex,redIndex,blueIndex)
for ccnt=1,table.getn(a),1 do
if ccnt < yellowEndIndex then
colors[ccnt] = "yellow"
elseif ccnt == redIndex then
colors[ccnt] = "red"
elseif ccnt == blueIndex then
colors[ccnt] = "blue"
else
colors[ccnt] = "white"
end
end
end
try(refreshColors, function(e)
print("Error Occured - "..e)
end)
refreshColors(1,1,1)
print(colors[1])
refreshColors() 関数が呼び出されると、例外がスローされ、エラー メッセージは「エラーが発生しました - Trial.lua:11: number を nil と比較しようとしました」です。refreshColors() 関数にそのような比較がないのに例外が発生するのはなぜですか?