don't print brackets in util.strval if metatable __tostring is present
This commit is contained in:
@@ -65,7 +65,8 @@ end
|
|||||||
---@return string
|
---@return string
|
||||||
function util.strval(val)
|
function util.strval(val)
|
||||||
local t = type(val)
|
local t = type(val)
|
||||||
if t == "table" or t == "function" then
|
-- this depends on Lua short-circuiting the or check for metatables (note: metatables won't have metatables)
|
||||||
|
if (t == "table" and (getmetatable(val) == nil or getmetatable(val).__tostring == nil)) or t == "function" then
|
||||||
return "[" .. tostring(val) .. "]"
|
return "[" .. tostring(val) .. "]"
|
||||||
else
|
else
|
||||||
return tostring(val)
|
return tostring(val)
|
||||||
|
|||||||
Reference in New Issue
Block a user