lua-users home
lua-l archive

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


On 14 July 2010 12:54, Kevin Vermeer <reemrevnivek@gmail.com> wrote:
>
> which is useless for the point of this section of the documentation.  Eike's
> code:
>>
>> local pos = 1
>> for i=1,#arr do
>>   if arr[i] ~= nil then
>>     arr[pos],arr[i],pos = arr[i],nil,pos+1
>>   end
>> end
>
> on the other hand, performs a useful function, and is best expressed with
> the multiple assignment statement.
>
> --
>
> Kevin Vermeer
>
>

is it?

arr [ pos ] = arr [ i ]
arr [ i ] = nil
pos = pos + 1

seems fine to me....