Created
September 23, 2014 00:34
-
-
Save nefftd/fd5e932579f264c10cfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- With select('#') and recursion | |
do | |
local function _tsa(n,a,...) | |
if n > 0 then | |
return tostring(a),_tsa(n-1,...) | |
end | |
end | |
function tostringall(...) | |
local n = select('#',...) | |
if n > 0 then | |
return _tsa(n,...) | |
end | |
end | |
end | |
-- With an array | |
do | |
function tostringall(...) | |
local n = select('#',...) | |
local s = {...} | |
for i = 1,n do | |
s[i] = tostring(s[i]) | |
end | |
return unpack(s,1,n) | |
end | |
end | |
-- Note that you need to explicitly check how many values were passed with | |
-- select('#'...). #{...} is undefined if `...` contains nils |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment