[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Building recursive argument lists in a shorter way?
- From: Andrew Starks <andrew.starks@...>
- Date: Mon, 23 Sep 2013 11:20:23 -0500
I have many setter methods that handle properties that represent an
inventory of one or more objects of the same class (to borrow from
So that I don't need to write a "set_prop" and "set_props" function, I
write this quite a bit:
local function f(arg, ...)
if (...) then
return arg, f(...)
A more compact variant doesn't work:
local function f2(arg, ...)
return arg, (...) and f2(...)
...for more than two recursions.
It's not a big deal, at all, but if there was some way to get closer
to the second example, and still have it work for n arguments, I'd
like to know it.