lua-users home
lua-l archive

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


On Sunday 25 April 2004 20:03, Ashwin Hirschi wrote:
> > Hi Ashwin!  Thankyou for the answer.
>
> You're welcome.
>
> > Are you saying that the getn should not work, but indexing withthe
> > userdata should?
>
> Yes.

To find the number of elements in a regular table (i.e. one which is not an 
array), you'll need to count them:

function size(t) -- Returns number of elements in t
    local n = 0
    for k,v in pairs(t) do
        n = n+1
    end
    return n
end

-- Jamie Webb