[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tinsert()'s default pos?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 24 Apr 2001 20:40:13 -0300
>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