Skip to content

Instantly share code, notes, and snippets.

@nefftd
Created September 23, 2014 00:34
Show Gist options
  • Save nefftd/fd5e932579f264c10cfc to your computer and use it in GitHub Desktop.
Save nefftd/fd5e932579f264c10cfc to your computer and use it in GitHub Desktop.
-- 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