lua-users home
lua-l archive

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



On Sep 12, 2006, at 19:23, Jerome Vuarand wrote:

Perf is not very good, but syntax is short. Above all it does not
require any Lua syntax modification (only some semantics of your
tables).

Talking of which:

local aTable = setmetatable( {}, { __add = function( aTable, aValue ) aTable[ #aTable + 1 ] = aValue return aTable end } )

_ = aTable + "one"
_ = aTable + "two"
_ = aTable + "three"

for anIndex, aValue in ipairs( aTable ) do
        print( anIndex, aValue )
end

> 1       one
> 2       two
> 3       three