Hi all, there was a table constructor question confused me when I was testing with the following cases.
1.
tb={ 'b' , [1] = 'a' }
I found that tb[1] is 'b' but not 'a', I thought 'b' would be override but not.
2.
tb = { [1] = 'a' , 'b' ,[1]='c'}
I still got the tb[1]=='b' .
The PIL book tells that {"r","g","b"} is equivalent to {[1]="r",[2]="g",[3]="b"}, so in the above cases, I
thought tb={ 'b' , [1] = 'a' } would be translated by Lua to tb={ [1] = 'b' , [1] = 'a' } and tb[1] should be 'a',
but that's wrong.
I searched and got that the table stored in Lua has the array part and hash node part, keys are integers
which are not less then a specified number N would stored in the array part,so I though keys are all [1]
would be override by the following assignments,that all I know about this question.
could anyone explain for me? Thanks.
p.s. Forgive my poor English :P