|
On 12/11/2010 10:49 AM, steve donovan wrote:
table.insert(t, 1) table.insert(t, nil) table.insert(t, 3)why not just? t[1] = 1 t[3] = 3
Sorry for my terse response earlier.My point is that, although there is a way of creating a sparse table which works in a numeric for loop which (i.e. the # operator respects the number of elements the table was constructed with barring trailing nil's), there is no way of creating such a table procedurally. So it seems of limited value having the only way of creating such a table being with a table literal.
Of course, with the __len metamethod working for tables now, it's not hard to make it work, so it's a minor point, but perhaps not entirely moot. There is, after all, a way of distinguishing between being passed "nil" (a constant) and "none" (no value) from C.
Cheers, Richard