From a045b76ad27f3d04be4816209ccdb9144e200061 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Sep 2017 17:09:03 -0700 Subject: Fixed repr to use __tostring metamethod if present. --- utils.moon | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'utils.moon') diff --git a/utils.moon b/utils.moon index eb222fb..c439e8f 100644 --- a/utils.moon +++ b/utils.moon @@ -10,7 +10,10 @@ utils = { repr: (x, add_quotes=false)-> switch type(x) when 'table' - if utils.is_list x + mt = getmetatable(x) + if mt and mt.__tostring + mt.__tostring(x) + elseif utils.is_list x "{#{table.concat([utils.repr(i, true) for i in *x], ", ")}}" else "{#{table.concat(["[#{utils.repr(k, true)}]= #{utils.repr(v, true)}" for k,v in pairs x], ", ")}}" -- cgit v1.2.3