lua-users home
lua-l archive

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

This isn't pretty, but I've done things like this before:

function a(x,y,z)
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 <> wrote:
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
  func(arg, optarg2)

Names arguments are very cool in some cases ;-)


la vita e estrany