lua-users home
lua-l archive

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



On Aug 3, 2014 1:45 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
> ```

Put another way, a function defined list_keys(t, ...) puts (CAR args) in "t", and (CDR args) in "...".

The _expression_ (...) is (CADR args).

The Lisp-nature of Lua is close to the surface in this one....

Jay