[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Res: The table length is not correct
- From: Sérgio Medeiros <tampo_8@...>
- Date: Fri, 6 Mar 2009 04:34:35 -0800 (PST)
I think your table is not a valid array anymore, because it has a hole
in position 1. If you delete "bbbb", not "aaa", then your code works.
Sérgio
________________________________
De: zhu honglei <zhuhongleizhl@gmail.com>
Para: lua@bazar2.conectiva.com.br
Enviadas: Sexta-feira, 6 de Março de 2009 9:22:09
Assunto: The table length is not correct
All,
I come to a strange problem. the table length is not correct. (my set up is Lua5.1.3 in Linux)
local t={"aaa","bbbb"} for k, v in pairs(t) do
if v=="aaa" then t[k]=nil end
end
table.sort(t, function(x, y) return string.lower(x) < string.lower(y) end)
the error is: bad argument #1 to 'lower' (string expected, got nil)
It seems GC does not work well, the nil value pass to table.sort. Could someone explain why it is.
Or My code is wrong?
thanks in advance,
Best Regards,
Leon
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com