[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Little fun with vararg
- From: Andrew Starks <andrew.starks@...>
- Date: Sun, 3 Aug 2014 00:47:24 -0500
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