lua-users home
lua-l archive

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

Tables can't be used so easily as array() in PHP. All Lua developers should know their peculiarities to use them properly: distinctions between vector and hash parts, no count() function, maybe vector and hash parts grew strategy, etc.

My question is simple. If I have some collection of objects in vector part and I create holes by setting nil to middle elements, length operator and ipairs begin work improperly, how to I traverse this collection? Only with pairs() or should I use table.getn(), which seems have been removed in Lua 5.2? Or should I create element called "n" in hash part and create add/remove functions for collection? What are best practices for that case?