lua-l archive
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Subject
:
Suspicious table initialization
From
: Grzegorz Krasoń <grzegorz.krason@
...
>
Date
: Tue, 27 Oct 2020 20:27:22 +0100
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?
```lua
> t1 = {[3] = 100}
> t2 = {nil, nil, 100}
> for x, y in pairs(t1) do print(x, y) end
3 100
> for x, y in pairs(t2) do print(x, y) end
3 100
> #t1
0
> #t2
3
```
Follow-Ups
:
Re: Suspicious table initialization
,
Matthew Wild
Re: Suspicious table initialization
,
Javier Guerra Giraldez
Prev by Date:
Returning nil vs returning nothing
Next by Date:
Re: Returning nil vs returning nothing
Previous by thread:
Re: Returning nil vs returning nothing
Next by thread:
Re: Suspicious table initialization
Index(es):
Date
Thread