lua-users home
lua-l archive

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


On Sun, Aug 3, 2014 at 12:44 AM, Andrew Starks <andrew.starks@trms.com> wrote:
> Return the keys in a table (any order):
>
> ```
> local function list_keys(t, ...)
>     if next(t, (...)) then
>         return list_keys(t, next(t, (...)), ...)
>     else
>         return ...
>     end
> end
> ```


Forgot to post the output:

local test = {eat = true, babies = true, anom = true, nom =true, nomm= true}

print("-->",table.concat({list_keys(test)}, "\n-->\t"))
--> anom
--> nom
--> nomm
--> babies
--> eat