lua-users home
lua-l archive

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


Interesting part! Just one short question: What does the part

stuff[ #stuff+1 ]

Is the use of # a official part of Lua for the length of the tablearray?

Best Regards
Micha


Elbers, H.P. schrieb:
A smal example:

#!/usr/bin/env lua

require("lxp")
local stuff = {}

xmldata="<Top><A/> <B a='1'/> <B a='2'/><B a='3'/><C a='3'/></Top>"

function doFunc(parser, name, attr)
  if not (name == 'B') then return end
  stuff[#stuff+1]= attr
end

local xml = lxp.new{StartElement = doFunc}
xml:parse(xmldata)
xml:close()

print(stuff[2].a)
==> 2