mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Fixed lume.trace() to handle and print nil
argument
This commit is contained in:
parent
09847bd266
commit
8a2765a41b
13
lume.lua
13
lume.lua
@ -34,6 +34,7 @@ local iscallable = function(x)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function lume.clamp(x, min, max)
|
||||
return x < min and min or (x > max and max or x)
|
||||
end
|
||||
@ -344,13 +345,13 @@ end
|
||||
|
||||
|
||||
function lume.trace(...)
|
||||
local function stringify(x)
|
||||
x = (type(x) == "number") and lume.round(x, .01) or x
|
||||
return tostring(x)
|
||||
end
|
||||
local info = debug.getinfo(2, "Sl")
|
||||
local head = "[" .. info.short_src .. ":" .. info.currentline .. "] "
|
||||
print(head .. table.concat(lume.map({...}, stringify), " "))
|
||||
local t = { "[" .. info.short_src .. ":" .. info.currentline .. "]" }
|
||||
for i = 1, select("#", ...) do
|
||||
local x = select(i, ...)
|
||||
t[#t + 1] = (type(x) == "number") and lume.round(x, .01) or (x or "nil")
|
||||
end
|
||||
print(table.concat(t, " "))
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user