lua-users home
lua-l archive

Re: CHanging the order of parameters, is that possible?

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

AltStyle によって変換されたページ (->オリジナル) /