From 8a2765a41bbd86668c0d3bcbe87d90a05f6960cb Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 18 Apr 2014 19:09:59 +0100 Subject: [PATCH] Fixed lume.trace() to handle and print `nil` argument --- lume.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lume.lua b/lume.lua index beb99d2..491be3d 100644 --- a/lume.lua +++ b/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