lua-users home
lua-l archive

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

> Another way to put it: does pairs() always enumerate first what would be
> enumerated by ipairs(), then the rest of the table?

No. Although lua_next does traverse the array part first, there may be
entries for the list part in the hash part. Here is an example. You
may have to run it a few times to see this.

% cat a
for k,v in pairs(a) do print(k,v) end

% lua -v a
Lua 5.4.0  Copyright (C) 1994-2020, PUC-Rio
1 10
2 20
3 30
4 40
foo bar
5 50