Subscribe to this Thread
(Receive email notifications)
Pin To Profile
It would be very handy if the built in tostr() was able to call the __tostring() metamethod for tables that have it defined. This is easy enough to add in our own code, but feels like it should be default behavior, similar to normal Lua.
local _tostr=tostr
local function tostr(n,...)
if(type(n)=="table" and getmetatable(n) and getmetatable(n).__tostring)return getmetatable(n).__tostring(n,...)
return _tostr(n,...)
end