lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> rt={}
>
> rt[var]={[pa1]=va1}
>
> rt[var]={[pa2]=va2} -- does not add pair
>
You want that last statement to add the key/value pair [pa2]=va2 to
the table rt[var] ? If so:

rt[var][pa2] = va2

The meaning of your instructions:

rt={} -- Set rt to be an empty table
rt[var]= {[pa1]=va1} -- Set rt[var] to be a table containing the
key/pair [pa1] = va1
rt[var]= {[pa2]=va2} -- Set rt[var] to be a table containing the
key/pair [pa2] = va2

The last instruction doesn't add a pair to an existing table, because
it is overwriting the existing table