Log In  

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.

P#72548 2020-01-31 23:21

Yes please!

P#72552 2020-02-01 00:00
1
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
P#72593 2020-02-02 02:57

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-16 19:56:37 | 0.005s | Q:12