[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Documenting Lua gotchas for newbies.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 3 Dec 2010 12:43:51 -0200
> imagine that every table keeps a 'proper' length field, and #t returns it:
>
> t={1,2,3} => #t = 3
> t[2] = nil => #t = 3
> t[3] = nil => #t =.... ? should be 1, right?
Maybe; it could be 3 too. It is impossible to know whether you are
erasing element t[3] or simply changing its value to nil ;) After all,
the whole point is to allow nils into arrays. (With no nils, the
current # works fine.)
-- Roberto