Reputation: 355
If I unpack then pack an array:
arr = {1, 2, 3, 4, 5}
arr = table.pack(table.unpack(arr))
Will I guarantee that the resulting arr
is the same as the initial arr
?
In the documentation it states:
Note that the resulting table may not be a sequence.
What does this mean?
Upvotes: 1
Views: 6366
Reputation: 72312
The documentation you cite is talking about nils as in
table.pack(1,nil,3)
.
Your table is a sequence and so table.unpack(arr)
outputs no nils and table.pack(table.unpack(arr))
is a sequence.
However, table.pack(table.unpack(arr))
differs from the original arr
because it contains a field n
with value 5. This is the only difference.
Upvotes: 4