forked from pyrex/chameleonic
Golf tostring()
This commit is contained in:
parent
58bf1d70bf
commit
137a390b65
@ -177,30 +177,14 @@ function kbd:release(i)
|
||||
end
|
||||
|
||||
function tostring(any)
|
||||
if type(any)=="function" then
|
||||
return "function"
|
||||
end
|
||||
if any==nil then
|
||||
return "nil"
|
||||
end
|
||||
if type(any)=="string" then
|
||||
return any
|
||||
end
|
||||
if type(any)=="boolean" then
|
||||
if any then return "true" end
|
||||
return "false"
|
||||
end
|
||||
if type(any)=="table" then
|
||||
local str = "{ "
|
||||
for k,v in pairs(any) do
|
||||
str=str..tostring(k).."->"..tostring(v).." "
|
||||
end
|
||||
return str.."}"
|
||||
local str = "{ "
|
||||
for k,v in pairs(any) do
|
||||
str=str..tostring(k).."->"..tostring(v).." "
|
||||
end
|
||||
return str.."}"
|
||||
end
|
||||
if type(any)=="number" then
|
||||
return ""..any
|
||||
end
|
||||
return "unknown" -- should never show
|
||||
return tostr(any)
|
||||
end
|
||||
|
||||
-->8
|
||||
|
Loading…
Reference in New Issue
Block a user