From 137a390b65be102d1b45bb2298f828c702034d59 Mon Sep 17 00:00:00 2001 From: Nyeogmi Date: Thu, 22 Dec 2022 18:51:05 -0800 Subject: [PATCH] Golf tostring() --- chameleonic.p8 | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index 00bb6a9..33bbc49 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -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