lua-users home
lua-l archive

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

Ryan, the same is true of your first example and this example. 
inodes.tmp is asking for inodes['tmp'] and not inodes[tmp] witch is
what you want.  The changes are easy from:
> tmp = db.inode
> print(tmp)         --> 2340691
> print(inodes.tmp)  --> nil

tmp = dbinode
print(tmp)  --> 2340691
print(inodes[tmp])  --> kernlog.0

Using dot notation says give me the element named after the dot.  Using
brackets says give me the element named within the brackets.  Thus if
you use dot notation with a "variable" name then you are looking for
that variable's name not value.  To use the variables value you use
bracket notation.


t1 = {
  ['a'] = 3,
  tmp = 5,
  3 = 'three'

tmp = t1.a
-- tmp now holds 3
print(t1.tmp)  --> 5
print(t1[tmp]) --> three

Does that make more sense?

 - Jeremy

"Help I suffer from the oxymoron Corporate Security."