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"
print(x,y,z)
end

then you can do things like

a(nil,1) -- prints "dX 1 dZ"

along with many other variants.

-joe

On Fri, Dec 18, 2009 at 12:07 PM, spir <denis.spir@free.fr> wrote:
PS: There are certainly several techniques (eg thought at requiring a table for opt args). I'd like to review various possibilities.

Hello,

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 ;-)

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/