lua-users home
lua-l archive

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


2013/1/5 Marc Balmer <marc@msys.ch>:
> Is it possible to change the order of parameters in a function taking varargs?  Maybe using the select(n, ...) function?
>
> This is what I want to do:
>
> function foo(fmt, ...)
>     -- switch element 1 and 2 of {...}
>
>    print(string.format('%d %s', ...))
> end
>

function switch23(fmt,a,b,...)
  return fmt,b,a,...
end

function foo(fmt,...)
   print (string.format(switch23(fmt,...)))
end

foo('%d %s', 'first', 1)