[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: newbie: problems in reading table from lua
- From: David Given <dg@...>
- Date: Tue, 20 Dec 2005 19:16:06 +0000
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:
pgp4DhNYBMTCV.pgp
Description: PGP signature