lua-users home
lua-l archive

Re: newbie: problems in reading table from lua

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


On Tuesday 20 December 2005 19:20, Alexander Miro wrote:
[...]
> // the next function will return 0 (zero).
> // It should return 2 (two).... WHY NOT???
Because getn only works on tables used as arrays, not tables used as 
associative arrays, I'm afraid.
A table may contain some *numbered* items, and some *names* items. 
table.getn() (and the low-level luaL_getn()) both consider only the numbered 
items. In order to extract the names items you'll need to iterate through the 
table using lua_next().
-- 
+- David Given --McQ-+ 
| dg@cowlark.com | UN-altered REPRODUCTION and DISSEMINATION of this
| (dg@tao-group.com) | IMPORTANT information is ENCOURAGED
+- www.cowlark.com --+ 

Attachment: pgpKN4nvaEbKh.pgp
Description: PGP signature


AltStyle によって変換されたページ (->オリジナル) /