[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How do you cope with 2 or more optional parameters?
- From: Joseph Stewart <joseph.stewart@...>
- Date: Fri, 18 Dec 2009 12:10:05 -0500
This isn't pretty, but I've done things like this before:
local x = x or "dX"
local y = y or "dY"
local z = z or "dZ"
then you can do things like
a(nil,1) -- prints "dX 1 dZ"
along with many other variants.
On Fri, Dec 18, 2009 at 12:07 PM, spir <firstname.lastname@example.org>
PS: There are certainly several techniques (eg thought at requiring a table for opt args). I'd like to review various possibilities.
Well, I guess all is in title.
How you cope with a cas like the following:
func = function(param, optparam1, optparam2) dostuff end
Names arguments are very cool in some cases ;-)
la vita e estrany