diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-18 17:09:03 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-18 17:09:03 -0700 |
| commit | a045b76ad27f3d04be4816209ccdb9144e200061 (patch) | |
| tree | 8e89dec8ae84f78d86d11ea1197ad4f7a51ea4f5 /utils.moon | |
| parent | 7087dc5151fd08e8fc64ab2b6d3248ff0f13c271 (diff) | |
Fixed repr to use __tostring metamethod if present.
Diffstat (limited to 'utils.moon')
| -rw-r--r-- | utils.moon | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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], ", ")}}" |
