|
Am 01.07.2016 um 13:30 schröbte Martin:
On 16-06-30 05:11 PM, Tim Hill wrote:What about {1, [3]=3, 2} ? {1, [2]=2, 2} ? etc2 and 2. The largest implicit key. As I said, this is the *least* surprising, not that it has no surprises at all.Huh. And what length of sequence should be after local t = {1, [2]=2, 2} table.remove(t, 2) --print(t[2]) ?
That's easy (well, at least it would be the same as it is now): `nil`. To quote from the manual:
Finally, fields of the form exp are equivalent to [i] = exp, where i are consecutive integers starting with 1. Fields in the other formats do not affect this counting.
... so the `[2]=2` doesn't affect the index of the following `2` at all.
I think, better approach is to explicitly separate array part from hash part. But then we need separate indexing method for array part. Maybe syntax like "a.2" ?
And `a.2` and `a[2]` could have different values?! That doesn't seem like a good idea ...
Philipp