lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>I know there is a restriction when it come to string index (i.e. they 
>start at 1) but there is no such restriction on tables, so why does 
>tinsert not start at index 0?

For consistency with table expressions: t={10,20,30} sets t[1] to 10, not
t[0] to 10.

If you really want to start with zero, try

	t={n=-1}
	tinsert( t, "A" )
	tinsert( t, "B" )
	tinsert( t, "C" )
	print(getn(t),t[0],t[1],t[2])

But remember that your loops should now start at 0 too:

	for i=0 to getn(t) do ... end


--lhf