On Tue, 27 Oct 2020 at 14:27, Grzegorz Krasoń <

[hidden email]> wrote:

>

> How to understand the difference between t1 and t2 in the example below? They give the same results while iterating, but `#` returns different values.

> Is this expected?

yes

> > t1 = {[3] = 100}

> > t2 = {nil, nil, 100}

these are two different tables with equal contents. the difference is

that they are independent objects.

the `#` operator returns a number such that t[#t+1] == nil and either

#t == 0 or t[#t] ~= nil.

in both t1 and t2 it would be valid to return either 0 or 3. which

one is undefined.

--

Javier