Re: Table array performance improvement using dot notation
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Table array performance improvement using dot notation
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2014年3月17日 09:27:45 -0300
> local a = {}
> for i = 1, arg[1] do a.i = i * i end
This is not doing what you think it is: it is setting just one entry in the
table, the one with key "i". Check the contents of the table after the loop.
In general, a.x is sugar for a["x"]. Even if x happens to be the name of
a variable, in a.x it is used as a string, not a variable.