lua-users home
lua-l archive

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


> Could x[] be syntactic sugar for x[#x+1] ?
> It would make appending to lists so much nicer.

I usually avoid much of this notation by initializing x with
a 'push' method:

do
local push = function(self,item) self[1+#self] = item end
local x = { push = push }
....
x:push(expr)
...
end

I suppose it is a bit slower.

-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/