Thanks for your help so far.

Is there a decent way to determine the length of a non-integer-indexed
table?
All I can think of is to use something like

function table_is_empty(table)
    for i in pairs(table) do
         return false
    end
    return true
end

Coming from my background (Python, Java, PHP) that seems ugly and hackish.
If that's the lua Way To Do Things, though, then I'll do it.


On 18 September 2010 11:40, immerrr <[email protected]> wrote:

> Hi, Eliot.
> See the answers inline.
>
>
>  I'm very new to lua, and I've found the official documentation very dense.
>> I /think/ # evaluates the length of a table, but I'm not sure.
>>
> Tables are implemente in 2 parts in lua: array part (indices are integers)
> and map part. # evaluates to length of array part of a table, i.e.
> "#{1,2,3} = 3" but "#{["a"] = 4, ["b"] = 5} = 0"
>
>  Does 0 evaluate to false in lua?
>>
> You can easily test in the lua interpreter. Just run 'lua' and type in the
> test:
> > if 0 then
> print ('a')
> else
> print ('b')
> end
> a
>
>  What on earth is the difference between object.function() and
>> object:function()
>>
> object:function(...) literally means object.function(object, ...)
>
>>
>> Thank you all!
>>
>> Eliot
>>
> Sorry, don't have the time to look into your code right now.
>
> --- immerrr
>
> --
> To unsubscribe, send mail to [email protected].
>

Reply via email to