# operator (was: Re: [Benchmark] Numeric for loop vs. ipairs())
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: # operator (was: Re: [Benchmark] Numeric for loop vs. ipairs())
- From: Tomas Guisasola Gorham <tomas@...>
- Date: Thu, 7 May 2009 09:18:54 -0300 (BRT)
On Wed, 6 May 2009, Javier Guerra wrote:
#t gives you a number such that t[#t]==nil and t[#t-1] ~= nil ; but that could be any such number. if there's holes in the table, #t could be any of the holes, or the 'length' of the array
The whole idea is correct, but there is a small mistake:
t[#t+1] == nil and t[#t] ~= nil
An example:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
t={}; t[1]=1; t[3]=3; print(#t)
1
Tomás